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

Make array bounded GridColumn invisible

1 Answer 20 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Einar
Top achievements
Rank 1
Einar asked on 30 Aug 2008, 03:00 PM
Hey guys
well, topic says all i want to know: How can i set a Column to Invisible when my GridView is bounded to a DataTable.
i thought its maybe possible with a ColumnCreated event, but i didnt get it runnning..

Or if i could change the text in the secound coloumn for every row would also be ok

thanks

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 01 Sep 2008, 06:44 AM
Hello Einar,

You can hide a column in the PreRender event after data is bound as shown below.
cs:
protected void RadGrid1_PreRender(object sender, EventArgs e) 
    {       
       foreach (GridColumn col in RadGrid1.Columns) 
        { 
            if (col.UniqueName == "Name") 
            { 
                col.Visible = false
            } 
        } 

Or if you want to change the text for a particular column for every row you can check out the code given below.
cs:
protected void RadGrid4_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            item ["ColumnUniqueName"].Text = "CustomText"
        } 

Princy.

Tags
Grid
Asked by
Einar
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or