Hi,
I have a grid with two GridButtonColumn columns. In the ItemCommand event handler I want to extract the key value of the clicked row. First, I've used the following technique:
It worked with one of the columns but soon I've found out that it doesn't work with the other one. In this case it always extract the key value from the very first row. So I've used another technique (directly from your documentation):
This technique works with the second column but - surprise, surprise :-) - it doesn't work with the first one (where e.CommandArgument is always empty).
OK, I can deal with it (when e.CommandArgument is empty use one technique, when not empty - another) but I'm curious, what is the rule. I don't set the CommandArgument value explicitly - in any case. The columns are not designed identically but the differences seem to be not vital:
The worst is that I've tried to reproduce all that stuff in a test application but I've failed (only the first technique worked - e.CommandArgument was always empty).
Can the authors of RadGrid check, when they set CommandArgument to the index in the Items collection and when - not?
PS.
I'm using Q1 2010 version of RadControls for ASP.NET Ajax
I have a grid with two GridButtonColumn columns. In the ItemCommand event handler I want to extract the key value of the clicked row. First, I've used the following technique:
var keyValue = (e.Item
as
GridDataItem).GetDataKeyValue(
"keyField"
));
It worked with one of the columns but soon I've found out that it doesn't work with the other one. In this case it always extract the key value from the very first row. So I've used another technique (directly from your documentation):
GridDataItem item = MyGrid.Items[
int
.Parse(e.CommandArgument)];
var keyValue = item.GetDataKeyValue(
"keyField"
);
This technique works with the second column but - surprise, surprise :-) - it doesn't work with the first one (where e.CommandArgument is always empty).
OK, I can deal with it (when e.CommandArgument is empty use one technique, when not empty - another) but I'm curious, what is the rule. I don't set the CommandArgument value explicitly - in any case. The columns are not designed identically but the differences seem to be not vital:
- CommandName standard (RadGrid.DeleteCommandName) / non-standard
- ImageUrl declared / declared but further adjusted dynamically (ItemDataBound, ImageButton control found, its ImageUrl attribute adjusted)
- not sortable / sortable
The worst is that I've tried to reproduce all that stuff in a test application but I've failed (only the first technique worked - e.CommandArgument was always empty).
Can the authors of RadGrid check, when they set CommandArgument to the index in the Items collection and when - not?
PS.
I'm using Q1 2010 version of RadControls for ASP.NET Ajax