|
-
Oct 11th, 2002, 02:00 AM
#1
Thread Starter
Hyperactive Member
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?
Last edited by jeba; Oct 11th, 2002 at 02:57 AM.
J£ßä
-
Oct 11th, 2002, 02:33 AM
#2
Hyperactive Member
hi Jeba
try with the following code
Code:
Sub dbgrid_Edit(Sender As Object, E As DataGridCommandEventArgs)
dgrid.EditItemIndex = CInt(E.Item.ItemIndex)
BindGrid()
Dim tblRow As TableRow
tblRow= e.Item.FindControl("txtTdate").Parent.Parent
tblRow.Attributes.Add("OnClick", "alert('hello');")
End Sub
best of luck
-
Oct 11th, 2002, 03:20 AM
#3
Thread Starter
Hyperactive Member
Hi Prasad!
I tried the following code and got an error:
Code:
Sub dgrid_Edit(Sender As Object, e As DataGridCommandEventArgs)
dgrid.EditItemIndex = CInt(e.Item.ItemIndex)
BindGrid()
Dim txtfdt As TextBox=CType(e.Item.FindControl("txtfdate"), TextBox)
lbl.text=txtfdt.text
End Sub
Error:
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Can you please tell me why this is happening? I have double checked the names of the controls.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|