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

[Solved] Setting the Property from Codebehind

3 Answers 368 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 1
Rahul asked on 27 Aug 2009, 02:10 PM
<MasterTableView ShowGroupFooter="True" Width="100%">
                        <GroupHeaderItemStyle Font-Bold="true" ForeColor="Yellow" />
                      
                        <%--   <Columns>
                            <telerik:GridBoundColumn  HeaderText="Proposals" SortExpression="Proposal_ID" UniqueName="Proposal_ID">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn  DataType="System.Int32" FooterText="Total : " Aggregate = "Count"
                                HeaderText="EstTrials" SortExpression="EstTrials" UniqueName="Trials :">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataType="System.Decimal" Aggregate="Sum"
                               DataFormatString ="{0:c}"  HeaderText="EstCost" SortExpression="EstCost" UniqueName="Cost :">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn  HeaderText="CropName" Visible ="false"
                                SortExpression="CropName" UniqueName="CropName">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn HeaderText="ProdName"  Visible ="false"
                                SortExpression="ProdName" UniqueName="ProdName">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn  HeaderText="TerritoryName"  Visible ="false"
                                ReadOnly="True" SortExpression="TerritoryName" UniqueName="TerritoryName">
                            </telerik:GridBoundColumn>
                            <telerik:GridButtonColumn ButtonType ="ImageButton" ImageUrl ="images/Delete.gif" HeaderText ="Remove">
                                          
                            </telerik:GridButtonColumn>
                        </Columns>--%>
                    </MasterTableView>


I want to set the all above property through code behind in VB.net ...... I want to hide last 3 columns
I hv bind the data to radgrid throght databind from codebehind, but it binds all columns from code .... How to set visiblilty of columns?

Thnkas
Regards
Rahul

3 Answers, 1 is accepted

Sort by
0
Casey
Top achievements
Rank 1
answered on 27 Aug 2009, 02:32 PM
Hi Rahul,

In my RadGrid I have set both the Display and Visible properties to false for the columns I do not want to display. In the code below I've added my suggestion to the three columns where you have already set the Visible property to false. Let me know if this works.

<telerik:GridBoundColumn  HeaderText="CropName" Visible ="false" Display="false"   
                                SortExpression="CropName" UniqueName="CropName">  
</telerik:GridBoundColumn> 
<telerik:GridBoundColumn HeaderText="ProdName"  Visible ="false"  Display="false"   
                                SortExpression="ProdName" UniqueName="ProdName">  
</telerik:GridBoundColumn> 
<telerik:GridBoundColumn  HeaderText="TerritoryName"  Visible ="false"  Display="false"   
                                ReadOnly="True" SortExpression="TerritoryName" UniqueName="TerritoryName">
</telerik:GridBoundColumn>

Thanks,
Casey
0
Accepted
Princy
Top achievements
Rank 2
answered on 28 Aug 2009, 04:32 AM
Hi Rahul,

Try the following code snippet in the PreRender event of the Grid  to hide a column.

VB:
 
 
 
   Protected Sub RadGrid1_PreRender(ByVal sender As ObjectByVal e As EventArgs) 
        
        RadGrid1.MasterTableView.GetColumn("CropName").Display = False 
        RadGrid1.MasterTableView.GetColumn("ProdName").Display = False 
            
        RadGrid1.MasterTableView.GetColumn("TerritoryName").Display = False 
    End Sub 
 
 


Thanks
Princy
0
Rahul
Top achievements
Rank 1
answered on 28 Aug 2009, 05:31 AM
Casey Thanks you very much for reply
Tags
Grid
Asked by
Rahul
Top achievements
Rank 1
Answers by
Casey
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Rahul
Top achievements
Rank 1
Share this question
or