One Thing I Don't Like About GridView

J

Jonathan Wood

I like the GridView control and have been using it quite a bit. But there's
one thing I find I need to do all the time and it always seems like a big
pain.

I routinely need to add custom commands to each row. The problem is that
none of the command events provide any information about which row the
command was clicked on. Instead, I need to handle something like the
RowDataBound event for each and every row (how efficient is that), and in
that event I need to write code to find the command control in order to
change it's CommandArgument property.

So I end up with stuff like e.Row.Cells[2].Controls[2] or
e.Row.Cells[2].FindControl("xxx"). Both these forms are very brittle and
will break if my columns are rearranged, and the first form is broken if I
change the controls in the column.

Am I the only one who is troubled by this? Or perhaps someone who does this
all the time knows of an easier way? Why didn't MS make this a little
easier?

Thanks.

Jonathan
 

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

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top