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

[Solved] When accessing a hidden column, it makes it visible

1 Answer 107 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Clarence Klopfstein
Top achievements
Rank 1
Clarence Klopfstein asked on 22 Apr 2009, 07:43 PM
I have a grid with many columns in it.  I made several columns 'ReadOnly' and 'Display='false''.  When I accesss one of those columns in code behind it then shows up when the grid is refreshed, though with no real data, just this: "System.Data.DataRowView"

Here is the code that matters:
<telerik:GridTemplateColumn UniqueName="SetPrice" Display="false" HeaderText="SetPrice" HeaderStyle-Width="0px" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" ReadOnly="false">  
                        <ItemTemplate> 
                            <asp:Label ID="lblSetPrice" runat="server" Text='<%# Eval("SetPrice") %>'></asp:Label> 
                        </ItemTemplate> 
                    </telerik:GridTemplateColumn> 

AND:
        private void SetTotalAmount()  
        {  
            double total = 0;  
            foreach (GridDataItem item in grdContractItems.Items)  
            {  
                Label lblMetalValue = (Label)item.FindControl("lblExPrice"as Label;  
                Label lblLabor = (Label)item.FindControl("lblExPrice"as Label;  
                Label lblPrice = (Label)item.FindControl("lblExPrice"as Label;  
                Label lblExPrice = (Label)item.FindControl("lblExPrice"as Label;  
                Label lblSetPrice = (Label)item.FindControl("lblSetPrice"as Label;  
                if (lblSetPrice.Text != "0")  
                {  
                    lblMetalValue.Text = lblLabor.Text = lblPrice.Text = "";  
                    lblExPrice.Text = lblSetPrice.Text;  
                }  
                if (lblExPrice != null && lblExPrice.Text.Trim() != string.Empty)  
                {  
                    total += double.Parse(lblExPrice.Text);  
                }  
            }  
            lblTotalAmount.Text = GetDollar(total.ToString());  
        } 

1 Answer, 1 is accepted

Sort by
0
Pavel
Telerik team
answered on 27 Apr 2009, 08:40 AM
Hi Clarence,

I have prepared a simple sample implementing a similar functionality which works as expected on my end. Take a look at it and let me know how to modify it in order to reproduce the problem.

Kind regards,
Pavel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Clarence Klopfstein
Top achievements
Rank 1
Answers by
Pavel
Telerik team
Share this question
or