Attributes in Grid- Urgent!
Hi there!
I am using a datagrid with editlinkbutton. So when you edit a row, the values are displayed in textboxes for editing.
Now I want to run some client side Javascript code on a particular textbox. For ex, when you click on a textbox,
I want to show a datepicker by passing the next textbox value also.
Code:
<asp:TemplateColumn HeaderText="From Date">
<ItemTemplate>
<asp:Label width="80px" ID="lblfdate" runat="server" Text='<%# ConvertDate(DataBinder.Eval(Container.DataItem, "fromdate")) %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox width="80px" readonly="true" onclick="ShowDpicker(this,popCal,100,200,'1/Jan/1950',txtTdate.value)" runat="server" id="txtfdate" Text='<%# DataBinder.Eval(Container.DataItem, "fromdate") %>' />
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="To Date">
<ItemTemplate>
<asp:Label width="80px" ID="lblTdate" readonly="true" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Todate") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox width="80px" runat="server" id="txtTdate" Text='<%# DataBinder.Eval(Container.DataItem, "Todate") %>' />
</EditItemTemplate>
</asp:TemplateColumn>
When I click on the 'txtfdate', I am getting a client side error saying, 'txtTdate' is not declared.
I understand that ASP.NET engine creates names for the controls
in the datagrid at the runtime and send it to the browser.
My question is, how do I pass the 'txtTdate' in the 'ShowDatepicker' function of 'txtfdate'?
Can you please help me?