I am trying to programmatically set the checked property of a checkboxcolumn from a db column that is not of boolean type.
I followed the code examples posted in
http://www.telerik.com/community/forums/thread/b311D-bahhdt.aspx
and
http://www.telerik.com/community/forums/thread/b311D-bagkkb.aspx
so I used
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
CheckBox chk = (CheckBox)item.FindControl("CUST_ACTIVE");
chk.Checked = (item.GetDataKeyValue("CUST_ACTIVE").ToString() == "Y");
}
}
in this way chk is = null
using the second post way
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
CheckBox chk = (CheckBox)item.DataItem["CUST_ACTIVE"].Controls[0];
}
}
get the compiler error
unable to use [] index to an object expression.
Wich is the rigth way to acces a column using its uniquename property?
Thanks, Angdrak
I followed the code examples posted in
http://www.telerik.com/community/forums/thread/b311D-bahhdt.aspx
and
http://www.telerik.com/community/forums/thread/b311D-bagkkb.aspx
so I used
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
CheckBox chk = (CheckBox)item.FindControl("CUST_ACTIVE");
chk.Checked = (item.GetDataKeyValue("CUST_ACTIVE").ToString() == "Y");
}
}
in this way chk is = null
using the second post way
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
CheckBox chk = (CheckBox)item.DataItem["CUST_ACTIVE"].Controls[0];
}
}
get the compiler error
unable to use [] index to an object expression.
Wich is the rigth way to acces a column using its uniquename property?
Thanks, Angdrak