GridViewRowEventArgs versus EventArgs?

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
 
M

Morten Wennevik [C# MVP]

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?
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top