Click here to Skip to main content
16,017,207 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a textbox(fromdate) in itemtemplate of gridview which shows curentdate by default.
user click on the textbox so that a datetieme picker popups and selectd date set to the textbox.
problem is on which ever fromdate textbox is clicked from any row of girdview the datetime picker value is setting the value to the textbox on the first row, instead of set from current click of textbox
jquery used
C#
$(function () {
$("#fromdate").datepicker({
  changeMonth: true,
  changeYear: true,
  minDate: new Date(2012, 12, 1)
  });

});
Posted
Comments
Ashutosh Mahto 20-Aug-13 6:58am    
You may be using Id with ClientIDMode="static" for each of the textbox in gridview. Is it so?

Hello Reddy;

1st, you need to have the textbox in a template field object of the grid view as shown below:

Aspx
XML
<asp:GridView runat="server" ID="gridView1">
    <Columns>
        <asp:TemplateField>
            <ItemTemplate>
                <asp:Label Text='<%# Eval("hiredDate;) %>' runat="server" />
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox runat="server" Text='<%# Bind("hiredDate") %>' ID="hiredDateTextBox" CssClass="dateInput" />
            </EditItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>



Javascript
XML
<script>
    $(function () {
        var $grid = $("table[id$=gridView1]");
        var $tr = $("> tbody > tr:not(:has(th, table))", $grid);
        var $dateInputFields = $(".dateInput", $tr);

        $dateInputFields.datepicker();
    });
</script>


Hope this helps you?
 
Share this answer
 
Hi...
See this link using Ajax Calendar Control.
Ajax Calendar Control[^]
thank u.
 
Share this answer
 
Refer to this link. You will definitely be able to resolve this.

Implement jquery datepicker plugin in asp.net gridview control[^]

It states that:
Quote:
Since the ASP.Net GridView control repeats the textboxes it changes their ClientID hence we have used this LIKE selector so that it finds and applies the jQuery plugin to all textboxes.

Regards..:)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900