asp.net - Dynamic Gridview Template and Unique Control (ie textbox, label) IDs? -
When creating a gridview at design time, you can create a template column like this:
& Lt; ASP: TemplateField & gt; & Lt; ItemTemplate & gt; & Lt; ASP: label runat = "server" id = "label 1" & gt; & Lt; / Asp: label & gt; & Lt; / ItemTemplate & gt; & Lt; / ASP: TemplateField & gt;
And in HTML it will give it a unique name:
& lt; Span id = "gvSelect_ctl02_Label1" & gt; Blahblah & lt; / Span & gt;
And then I can refer to this label in the code behind it:
CType (e.row.FindControl ("Label1"), Label)
which is absolutely correct but I can not understand how to do this when I am dynamically creating a template field. I got the following code in "InstantiateIn":
Newly encoded HL.ID = "hHidden" hl.Value = 0 AddHandler hl.DataBinding as the HL, AddressOf Me.hl_DataBinding Container Control .Update (HL)
And it makes a hidden control with ID as it is hidden in each row but does not give it a unique ID like "gvSelect_ctl02_hHidden" Just "hHidden" and I know that there are ways to add line numbers to it. But I was thinking that this Wchalit was a way to do so. And yet allows me to reference hidden fields:
CType (e.ro.find control ("hHidden"), hindfield)
uh .. answer my own question. I was looking for the name in the cry-creative I should be looking for it at the RowDatabout event.
It works now .. Now that I am doing it correctly.
(Many things can happen when I go to.): S
Comments
Post a Comment