This is a migrated thread and some comments may be shown as answers.

[Solved] unable to a checkBoxColumn

1 Answer 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ang
Top achievements
Rank 1
ang asked on 22 Jan 2008, 03:55 PM
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


1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 23 Jan 2008, 02:21 PM
Hello ang,

Additional information on the proper way to access the items can be found in the following article. Essentially, based on the second approach, you can index the item["ColumnUniqueName"], and then the relevant controls nested in the cell.

Regards,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
ang
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or