How can I get textbox created ID in itemdatabound

  • Thread starter Ather Ali Shaikh
  • Start date
A

Ather Ali Shaikh

IHi All,

I have a Master grid under this master grid i have child grid in template column. FINE.

but int this child grid i have text box and buttons hard coded. When I bound the grid with datasource it binds. FINE.

On the time binding I add attribute to button to run javascript.

As

mytxtControl = CType(e.Item.FindControl("txtDate"), TextBox )
CType(e.Item.FindControl("btnGet"), Button ).Attributes("onclick","return ImageList(' " & mytxtControl.ID & " ')")
this returns
mytxtControl.ID = nothing
and in view source of html it shows: DGTestMaster:_ctl2:DGTestDetail:_ctl3:txtDate

I want to pass mytxtControl.ID to popup list against this textboxID

How can I do this.

Regards
Ather Ali Shaikh
 
T

Teemu Keiski

Did you try mytxtControl.ClientID ?

ClientID is the ID that is rendered to the client-side ID attribute and it
is client-script friendly.

If in this case even ClientID doesn't work, try either setting the ID
explicitly in the declarative syntax for the TextBox, if you haven't done
so. If you have already done that, move the code to DataGrid_PreRender, loop
through DataGrid's Items and get the TextBox from each of them (at this
point they have IDs for sure).

If this doesn't seem to help, post the declarative syntax and code for us to
check.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke


IHi All,

I have a Master grid under this master grid i have child grid in template
column. FINE.

but int this child grid i have text box and buttons hard coded. When I bound
the grid with datasource it binds. FINE.

On the time binding I add attribute to button to run javascript.

As

mytxtControl = CType(e.Item.FindControl("txtDate"), TextBox )
CType(e.Item.FindControl("btnGet"), Button ).Attributes("onclick","return
ImageList(' " & mytxtControl.ID & " ')")
this returns
mytxtControl.ID = nothing
and in view source of html it shows:
DGTestMaster:_ctl2:DGTestDetail:_ctl3:txtDate

I want to pass mytxtControl.ID to popup list against this textboxID

How can I do this.

Regards
Ather Ali Shaikh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top