I am trying to get some cell data from a grid that is bound to an ObjectDataSource.
In the ItemCommand event, when the CommandName is RowClick, I am trying to access e.Item.OwnerTableView.DataKeyValues but there are no columns on the OwenerTableView and no values in DataKeyValues.
It really seems to me like the Telerik controls, great as they are, are not very well made for some scenarios - ie ObjectDataSource.
Thanks
In the ItemCommand event, when the CommandName is RowClick, I am trying to access e.Item.OwnerTableView.DataKeyValues but there are no columns on the OwenerTableView and no values in DataKeyValues.
It really seems to me like the Telerik controls, great as they are, are not very well made for some scenarios - ie ObjectDataSource.
Thanks
5 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 17 Jun 2008, 05:29 AM
Hi David,
Try the following code snippet.
CS:
Thanks
Shinu.
Try the following code snippet.
CS:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) |
{ |
if (e.CommandName == "RowClick") |
{ |
GridDataItem item = (GridDataItem)e.Item; |
string strKey = item.GetDataKeyValue("CustomerID").ToString(); |
} |
} |
Thanks
Shinu.
0
david
Top achievements
Rank 1
answered on 17 Jun 2008, 01:44 PM
Hi Shinu,
I have tried that, but my columns do no seem to exist:
If I look in e.Item.OwnerTableView my columns are in the AutoGeneratedColumns array but not in the Columns array. The Unique name of the column there is correct - "RR_REP".
Thanks.
I have tried that, but my columns do no seem to exist:
'item.GetDataKeyValue("RR_REP")' threw an exception of type 'System.ArgumentOutOfRangeException'
If I look in e.Item.OwnerTableView my columns are in the AutoGeneratedColumns array but not in the Columns array. The Unique name of the column there is correct - "RR_REP".
Thanks.
0
Shinu
Top achievements
Rank 2
answered on 18 Jun 2008, 04:00 AM
Hi David,
Have you set "RR_REP" as the DataKeyName? Try setting it as the DataKeyName as shown below.
ASPX:
Thanks
Shinu.
Have you set "RR_REP" as the DataKeyName? Try setting it as the DataKeyName as shown below.
ASPX:
<MasterTableView DataKeyNames="RR_REP" > |
Thanks
Shinu.
0
david
Top achievements
Rank 1
answered on 18 Jun 2008, 04:26 PM
Yes that works thanks.
How do you get non key columns though? Or does it not matter if you add non key columns to the KeyColumnNames list?
I guess there must be some documentation that I have not seen that explains all of this, can you point me to where that is located? I think a lot of my problems must be due to the fact that I have missed some important doc file somwhere - I have pretty much only seen the examples.
Thanks
How do you get non key columns though? Or does it not matter if you add non key columns to the KeyColumnNames list?
I guess there must be some documentation that I have not seen that explains all of this, can you point me to where that is located? I think a lot of my problems must be due to the fact that I have missed some important doc file somwhere - I have pretty much only seen the examples.
Thanks
0
Shinu
Top achievements
Rank 2
answered on 19 Jun 2008, 05:56 AM
Hi David,
Refer the following help document links.
Retrieving primary key field values for selected items
Accessing cells and rows
Thanks
Shinu.
Refer the following help document links.
Retrieving primary key field values for selected items
Accessing cells and rows
Thanks
Shinu.