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_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DataItem("ReasonL").ToString = 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!