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

Check value in grid

1 Answer 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Panayiotis Pelekanos
Top achievements
Rank 1
Panayiotis Pelekanos asked on 12 Feb 2009, 06:06 PM
Hi there,

How can i check if a value in my gird in display mode is set to true or false? (the bound column is asp:checkbox)
I am trying to set an image visible status to true or false accordind to the grid column value.

Thanxs in advance

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 13 Feb 2009, 04:58 AM
Hello,

Try out the following code to set the visibility of an image based on whether a checkbox is checked for the same row in a grid.
aspx:
<telerik:GridCheckBoxColumn UniqueName="CheckBoxColumn" HeaderText="CheckBoxColumn" DataField="ToandFro"></telerik:GridCheckBoxColumn> 
<telerik:GridTemplateColumn UniqueName="TemplateColumn"
            <ItemTemplate> 
                <asp:Image ID="Image1" ImageUrl="~/images/image.gif" runat="server" />              
            </ItemTemplate> 
 </telerik:GridTemplateColumn> 

cs:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            CheckBox chkbx = (CheckBox)item["CheckBoxColumn"].Controls[0]; 
            if (!chkbx.Checked) 
            { 
                Image img = (Image)item.FindControl("Image1"); 
                img.Visible = false
            } 
        } 
   } 

Thanks
Princy.
Tags
Grid
Asked by
Panayiotis Pelekanos
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or