I have a GridCheckboxColumn in my grid and a need to create a GridTemplateColumn according to the checkbox is checked or not.
For instance,
line 1,
if the checkbox is checked the GridTempleColumn label displays “YES” ,
if the checkbox is not checked the GridTempleColumn label displays “NO”,
if the checkbox is NULL : it displays “N/A”.
To sum up, i have this in my aspx page:
<telerik:GridCheckBoxColumn DataField="facturable" DataType="System.Boolean" HeaderText="facturable"
SortExpression="facturable" UniqueName="facturable">
</telerik:GridCheckBoxColumn>
<telerik:GridTemplateColumn HeaderText="Type de tickets"
UniqueName="typedestickets">
<ItemTemplate><asp:Label id="test" runat="server"></asp:Label></ItemTemplate>
</telerik:GridTemplateColumn>
My try in code behind : ( not working )
protected void RadGrid1_DataBound(object sender, EventArgs e)
{
foreach (Telerik.Web.UI.GridDataItem dataItem in RadGrid1.MasterTableView.Items)
{
CheckBox chkDelete = (CheckBox)dataItem.FindControl("facturable");
Label label = (Label)dataItem.FindControl("test");
if (chkDelete.Checked == true) { label.Text = "MA"; }
}
}
Thank you in advance for your help
1 Answer