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

How to Hide One Colum if dont have any values

1 Answer 80 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ashok
Top achievements
Rank 1
Ashok asked on 17 Sep 2010, 11:52 AM
HI Team

How to i hide one Column if Rad Grid if i dont have any value in that colum while bringing values from database
i have one rad grid in that i'm using GridImageColumn, in GridImageColumn if i have url means it should have to show image , if dont have url means it should have to hide the particular column

See my code...

this is the Url for  DataImageUrlFields "~/UserImages/32.jpg"

<

 

telerik:RadGrid ID="grdtestcheck" runat="server" AutoGenerateColumns="False"

 

 

GridLines="None">

 

 

<MasterTableView>

 

 

<RowIndicatorColumn>

 

 

<HeaderStyle Width="20px" />

 

 

</RowIndicatorColumn>

 

 

<ExpandCollapseColumn>

 

 

<HeaderStyle Width="20px" />

 

 

</ExpandCollapseColumn>

 

 

<Columns>

 

 

<telerik:GridBoundColumn DataField="RepName" HeaderText="Name"

 

 

UniqueName="column">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridImageColumn DataImageUrlFields="RepUrl" HeaderText="Image" ImageAlign="Middle"

 

 

ImageHeight="50px" ImageWidth="75px" UniqueName="column1">

 

 

</telerik:GridImageColumn>

 

 

</Columns>

 

 

</MasterTableView>

 

 

</telerik:RadGrid>

Plese give me how to hide the column like above....

 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 17 Sep 2010, 12:06 PM
Hello Ashok,


The following code in PreRender event of grid will help you to hide the column.

CS:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    RadGrid1.MasterTableView.GetColumn("column1").Visible = false;       
}

[Iterate through the griditems and access the image control, check for the ImageUrl and hide/show the column accordingly using above code.]

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