GridViewRowEventArgs versus EventArgs?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Howdy All,

I don't understand how to correct an error I encounter when trying to
control GridView DataBound data flow.

error CS0123: No overload for 'GridView2_DataBound' matches delegate
'System.EventHandler'

protected void GridView2_DataBound(object sender,
GridViewRowEventArgs e)

String PartImageLocation =

Convert.ToString(System.Web.UI.DataBinder.Eval(e.Row.DataItem,
"PartImageLocation"));

Code is normally generated for:

protected void GridView2_DataBound(object sender, EventArgs e)

Or another way to ask the same question is can I dig into the data via
EventArgs instead of GridViewRowEventArgs (and how?)

Many thanks for any help you can provide,
Dale E. Moore
 
Howdy All,

I don't understand how to correct an error I encounter when trying to
control GridView DataBound data flow.

error CS0123: No overload for 'GridView2_DataBound' matches delegate
'System.EventHandler'

protected void GridView2_DataBound(object sender,
GridViewRowEventArgs e)

String PartImageLocation =
Convert.ToString(System.Web.UI.DataBinder.Eval(e.Row.DataItem,
"PartImageLocation"));

Code is normally generated for:

protected void GridView2_DataBound(object sender, EventArgs e)

Or another way to ask the same question is can I dig into the data via
EventArgs instead of GridViewRowEventArgs (and how?)

Many thanks for any help you can provide,
Dale E. Moore

Hi Dale,

The DataBound event is fired when the binding logic is completed. EventArgs is just the default argument and rarely contain any useful information, instead, call upon GridView2 directly to obtain information. What information are you trying to access?
 
Sounds like there might be a bit of confusion between GridView's DataBound
and RowDataBound events.
DataBound fires once only, when Databinding is complete, and requires a
handler that looks like this:

protected void GridView1_DataBound(object sender, EventArgs e)

RowDataBound fires once for each row in the GridView as it is being
databound, and requires a handler that looks like so:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)

Note the different types in the EventArgs parameter in each.
Hope that helps.
Peter
 
Back
Top