how to access control in templatefield gridview with custom id
Posted
by
Mohsen.Tavoosi
on Stack Overflow
See other posts from Stack Overflow
or by Mohsen.Tavoosi
Published on 2010-12-31T07:30:42Z
Indexed on
2010/12/31
8:53 UTC
Read the original article
Hit count: 355
i have a customized gridview.my grid is able to sort for each column just by 1 click in the header without any setting and overloading methods such as sorting,etc by user(programmer).(i do this successfully and work fine) users(programmers) maybe add each column in grid.such as template field,hyperlinkfield,boundfield... . for sorting, i must access datafield of columns. i can access boundfield column by this code.i can access datafield and header text and ... sample:
for (int j = 0; j < this.Columns.Count; j++)
{
BoundField bf;
bf = this.Columns[j] as BoundField;
if (bf != null)
{
string ht = bf.HeaderText;
string df = bf.DataField;
}
}
but i can access control in the templateField.such as ColumnBound. sample:
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
i want access "Name" (Bind ("Name") or Eval ("Name")) . how can i? there is a point: i dont now what is the ID (in this case "Label1") of control in templatefield. special thanks
© Stack Overflow or respective owner