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