I have a JQuery Datepicker bound correctly (I feel so) to the gridview. It works fine and shows perfectly on all textboxes of the grid and on each row.
The problem is that it outputs the value to only first row.
So when I click on 10th row of the grid, a DatePicker pops out on the 10th Row, but when I select a date, that date is filled in the first row of the grid only.
No matter which row I choose, it always outputs the value to first row only.
Any help would be greatly appreciated.
I have tried to attach the DatePicker through both textbox ID as well as the Class name with no luck.
Thanks
Ashutosh
$("#txtGivenDate").datepicker({ dateFormat: "dd/mm/yy", max: '0', changeYear: true, changeMonth: true });
And the grid markup is as below:
<asp:TemplateField HeaderText="Given Date" ControlStyle-Width="90%" HeaderStyle-Width="9%">
<ItemTemplate>
<asp:TextBox ID="txtGivenDate" runat="server" Text='<%#Bind("GivenDate")%>' BorderStyle="None"
CssClass="youpi"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
Tried all possible solutions
- Using Class name instead of ID
- Using IDs to identify the name of the textbox
- Using ClientIDMode=Static in the textbox declaration
- Attaching the JS from code behind on the RowCreated event of the gridview.
None seemed to work.
Thanks
Ashutosh
I think I figured out the answer.
Problem was with the ClientIDMode.
We need to set ClientIDMode of the textbox to “AutoID”.
Setting this worked well and problem was resolved.
Thanks everyone.