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

Show/Hide Grod Columns baed on selected view

1 Answer 20 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Colin Mulcahy
Top achievements
Rank 1
Colin Mulcahy asked on 03 Nov 2008, 11:37 PM
Hi,

I have a grid that has a number of columns that must be shown or hidden based on a selection from an external combobox.

Where is the best place(event) to place the code to show/hide these columns in an ajaxed gird? 

Page_Init, Page_Load or perhaps NeedDataSource?

Thanks

Colin

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 04 Nov 2008, 04:18 AM
Hi Colin,

You can show or the hide the column in the SelectIndexChanged event of the ComboBox.

ASPX:
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" Width="109px" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
          <asp:ListItem Text="ProductName" ></asp:ListItem> 
          <asp:ListItem  Text="SupplierID" ></asp:ListItem> 
        </asp:DropDownList> 

CS:
 protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) 
    { 
        string strSelectedItem = DropDownList1.SelectedItem.ToString(); ; 
        if (strSelectedItem == "ProductName") 
         
            RadGrid1.MasterTableView.GetColumn(strSelectedItem).Visible = true
         
        else if(strSelectedItem == "SupplierID") 
            RadGrid1.MasterTableView.GetColumn(strSelectedItem).Visible = true
        RadGrid1.MasterTableView.Rebind(); 
         
    } 


Thanks
Shinu.
Tags
Grid
Asked by
Colin Mulcahy
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or