Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
ASP .Net
ASP .Net Datagrid Control
ClintID does not work for datagrid template columns controls
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Teemu Keiski, post: 4258353"] I answered this on another group: It is because basically DataGrid's control hierarchy isn't "clear" yet, that is this item is just created and it hasn't been added to DataGrid's controls collection and therefore they have not been assigned full IDs yet. You could overcome the problem by attaching a handler for DataGrid's PreRender event and set the ID's there. My code is VB as I had VB IDE open by the time I read your question, hope it doesn't mind). Private Sub DataGrid1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.PreRender For Each dgi As DataGridItem In DataGrid1.Items Dim b As Button = CType(dgi.FindControl("b"), Button) Dim div As HtmlGenericControl = CType(dgi.FindControl("div"), HtmlGenericControl) Dim divClientID As String = div.ClientID Dim js As String = "javascript:setNewContent('" + divClientID + "');return false;" b.Attributes("onclick") = js Next End Sub And BTW it should work on ItemDataBound as well as on that phase item is added to the DataGrids controls. -- Teemu Keiski MCP,Designer/Developer Mansoft tietotekniikka Oy [URL]http://www.mansoft.fi[/URL] AspInsiders Member, [URL="http://www.aspinsiders.com"]www.aspinsiders.com[/URL] ASP.NET Forums Moderator, [URL="http://www.asp.net"]www.asp.net[/URL] AspAlliance Columnist, [URL="http://www.aspalliance.com"]www.aspalliance.com[/URL] [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
ASP .Net
ASP .Net Datagrid Control
ClintID does not work for datagrid template columns controls
Top