Doing this in VB.NET with VS2008.
I have a simple GridView with two columns. Column1 Header is called
"Reason" and the rows contain a Label called "ReasonL". Column2 header is
called Add/Edit and the row has a LinkButton called "AddEditLB" . Basically,
it looks like this.
Reason Add/Edit
ReasonL AddEditLB
All I want to do is make AddEditLB Text to say "Add" if ReasonL is
string.empty and "Edit" if it's not. This is what I tried in the
RowDataBound event and it didn't work:
Protected Sub GridView1_RowDa taBound(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Grid ViewRowEventArg s) Handles
GridView1.RowDa taBound
If e.Row.RowType = DataControlRowT ype.DataRow Then
If e.Row.DataItem( "ReasonL").ToSt ring = String.Empty Then
e.Row.DataItem( "AddEditLB" ) = "Add"
Else
e.Row.DataItem( "AddEditLB" ) = "Edit"
End If
End If
End Sub
Can someone tell me what I did wrong?
This is the error msg I got.
ReasonL is neither a DataColumn nor a DataRelation for table DefaultView.
Thanks!
I have a simple GridView with two columns. Column1 Header is called
"Reason" and the rows contain a Label called "ReasonL". Column2 header is
called Add/Edit and the row has a LinkButton called "AddEditLB" . Basically,
it looks like this.
Reason Add/Edit
ReasonL AddEditLB
All I want to do is make AddEditLB Text to say "Add" if ReasonL is
string.empty and "Edit" if it's not. This is what I tried in the
RowDataBound event and it didn't work:
Protected Sub GridView1_RowDa taBound(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Grid ViewRowEventArg s) Handles
GridView1.RowDa taBound
If e.Row.RowType = DataControlRowT ype.DataRow Then
If e.Row.DataItem( "ReasonL").ToSt ring = String.Empty Then
e.Row.DataItem( "AddEditLB" ) = "Add"
Else
e.Row.DataItem( "AddEditLB" ) = "Edit"
End If
End If
End Sub
Can someone tell me what I did wrong?
This is the error msg I got.
ReasonL is neither a DataColumn nor a DataRelation for table DefaultView.
Thanks!
Comment