L
louie
I have created a Gridview both using an ObjectDataSource and an SQLDataSource.
I amend attributes in a TemplateField, this works fine until I sort the
data, by clicking on the column heading, then i get the error in the
RowCreated Event
Run-time exception thrown : System.NullReferenceException - The pointer for
this method was null.
This is because the object e.Row.DataItem is set to Nothing.
I can replace this code with <%# CreateHTML(Eval("FieldName")) % > and
create inline HTML, this works fine. What am I missing?
Any help much appreciated.
Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
If e.Row.RowType = DataControlRowType.DataRow Then
Dim lName As String = DataBinder.Eval(e.Row.DataItem,
"FieldName").ToString
Dim lBut As Web.UI.WebControls.Button
lBut = e.Row.FindControl("tstBut")
lBut.Text = lName
End If
End Sub
I amend attributes in a TemplateField, this works fine until I sort the
data, by clicking on the column heading, then i get the error in the
RowCreated Event
Run-time exception thrown : System.NullReferenceException - The pointer for
this method was null.
This is because the object e.Row.DataItem is set to Nothing.
I can replace this code with <%# CreateHTML(Eval("FieldName")) % > and
create inline HTML, this works fine. What am I missing?
Any help much appreciated.
Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
If e.Row.RowType = DataControlRowType.DataRow Then
Dim lName As String = DataBinder.Eval(e.Row.DataItem,
"FieldName").ToString
Dim lBut As Web.UI.WebControls.Button
lBut = e.Row.FindControl("tstBut")
lBut.Text = lName
End If
End Sub