Telerik,
Im trying to get the value of a TemplateColumn item when the ItemCommand event is raised. My TemplateColumn looks like the following:
Basically, the template is built using a boolean value (determining if the current user logged in has EditRights to the record) to either display a LinkButton (to launch a custom edit screen) or to display a Label (if the current user doesn't have the appropriate permission).
In the ItemCommand, I would like to get the value of the data bound to either the Label or the LinkButton. The closest I got to getting the information is by doing something like the following:
Is this the only way to get the Text value of the GridLinkButton? Can you please provide any other information for retrieving the values associated with a TemplateColumn using the markup in my Template?
Thanks
Im trying to get the value of a TemplateColumn item when the ItemCommand event is raised. My TemplateColumn looks like the following:
<
telerik:GridTemplateColumn
HeaderText
=
"User"
UniqueName
=
"User"
Reorderable
=
"false"
Display
=
"true"
SortExpression
=
"User"
>
<
ItemTemplate
>
<
asp:LinkButton
ID
=
"btnButton1"
runat
=
"server"
ToolTip
=
"Edit this user"
CommandName
=
"EditUser"
Visible="<%# Master.UserPrefs.HasEditRights %>"><%# Eval("User") %></
asp:LinkButton
>
<
asp:Label
ID
=
"lblLabel1"
runat
=
"server"
Visible="<%#!Master.UserPrefs.HasEditRights %>"><%# Eval("User") %></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
Basically, the template is built using a boolean value (determining if the current user logged in has EditRights to the record) to either display a LinkButton (to launch a custom edit screen) or to display a Label (if the current user doesn't have the appropriate permission).
In the ItemCommand, I would like to get the value of the data bound to either the Label or the LinkButton. The closest I got to getting the information is by doing something like the following:
protected void gvUsers_ItemCommand(object sender, GridCommandEventArgs e)
{
RadGrid grid = (RadGrid)sender;
switch (e.CommandName.ToUpper())
{
case "MyCommandName":
foreach (GridDataItem item in grid.MasterTableView.Items)
{
string cellContent = ((GridLinkButton)item.Cells[3].Controls[0]).Text
}
break;
}
}
Is this the only way to get the Text value of the GridLinkButton? Can you please provide any other information for retrieving the values associated with a TemplateColumn using the markup in my Template?
Thanks