Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Difference between DataBind() and BoundField
Message
From
14/08/2014 16:54:59
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Difference between DataBind() and BoundField
Environment versions
Environment:
C# 5.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01605741
Message ID:
01605741
Views:
29
I'm running into a thing with a data edit WebForm trying to set a column's ReadOnly property.

Data is returned from SQL into a DataSet

GridView is defined as follows
   asp:GridView ID="GV1" runat="server" AutoGenerateEditButton="True" 
        CellPadding="10" CellSpacing="10" BorderStyle="Solid" 
        HorizontalAlign="Center" Caption="DashBoard Configuration Settings" 
        CaptionAlign="Top">
        EditRowStyle BackColor="#99CCFF" />
    /asp:GridView>
GridView GV1 is handled as follows

GV1.DataSource = GVSet;
GV1.DataBind()

The data displays in a grid, as one would expect, but when I get the ColumnIndex of the column that should be ReadOnly and then try to set it with
((BoundField)GV1.Columns[ColIndx]).ReadOnly = true;

I get an "index out of bounds" error because GV1.Columns.Count = 0

What am I missing, besides a deep and abiding understanding of c#?
"You don't manage people. You manage things - people you lead" Adm. Grace Hopper
Pflugerville, between a Rock and a Weird Place
Next
Reply
Map
View

Click here to load this message in the networking platform