kcwallace
Well-known member
I am attempting write an Webform using ASP 2.0.
I need to use a DataGridView. However, I cannot seem to find any sample code to manipulate a column using code behind. Specifically, I need to programatically hide a field from the datasource.
I cannot remove the field from the datasource, because I need it to make decisions
I use the code below to build the datagridview. I get an error at the noted location. THe error states:
"{"Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index"}"
However, I know there are 6 fields in the dataset.
[VB]
With GridView1
.DataMember = DS.Tables(0).TableName
.DataSource = DS
.AutoGenerateEditButton = True
.BorderStyle = BorderStyle.Solid
.BorderWidth = Unit.Pixel(10)
.EmptyDataText = "No Data Added"
.Columns(3).Visible = False Errors here.
.DataBind()
End With
[/code]
I have the AutogenerateColumns set to TRUE. However, if I set it to FALSE, nothing shows up.
I need to use a DataGridView. However, I cannot seem to find any sample code to manipulate a column using code behind. Specifically, I need to programatically hide a field from the datasource.
I cannot remove the field from the datasource, because I need it to make decisions
I use the code below to build the datagridview. I get an error at the noted location. THe error states:
"{"Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index"}"
However, I know there are 6 fields in the dataset.
[VB]
With GridView1
.DataMember = DS.Tables(0).TableName
.DataSource = DS
.AutoGenerateEditButton = True
.BorderStyle = BorderStyle.Solid
.BorderWidth = Unit.Pixel(10)
.EmptyDataText = "No Data Added"
.Columns(3).Visible = False Errors here.
.DataBind()
End With
[/code]
I have the AutogenerateColumns set to TRUE. However, if I set it to FALSE, nothing shows up.