
Richard Weeks
Top achievements
Rank 2
Richard Weeks
asked on 04 Oct 2010, 01:24 AM
If I have:
var radGrid = (RadGrid)source;
var selectedValue = radGrid.SelectedValue.ToString();
(it happens to be an int)
And if I then throw that selectedValue to another grid on another page view a querystring redirect, what's the most efficient way to select the relevant grid row (supposing that row exists with the equivalent value) given that SelectedValue doesn't have a Set accessor?
Thanks,
Richard
4 Answers, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 04 Oct 2010, 07:24 AM
Hello Richard,
I used following code to get the SeletedValue in code behind and used the value for creating the url query string.
C#:
-Shinu.
I used following code to get the SeletedValue in code behind and used the value for creating the url query string.
C#:
string
selectedValue = RadGrid1.SelectedValue.ToString();
-Shinu.
0

Richard Weeks
Top achievements
Rank 2
answered on 05 Oct 2010, 12:01 AM
Hi Shinu, you missed the point of the question (my fault as I just brain-dumped). I'm interested in what comes after:
"what's the most efficient way to select the relevant grid row (supposing that row exists with the equivalent value) given that SelectedValue doesn't have a Set accessor?"
I want to set the selected value based on ther previously retrieved value from SelectedValue, which I sent to the page in a querystring.
Getting it is no problem but how do I select that row based on the value, i.e. how to do:
Best,
Richard
"what's the most efficient way to select the relevant grid row (supposing that row exists with the equivalent value) given that SelectedValue doesn't have a Set accessor?"
I want to set the selected value based on ther previously retrieved value from SelectedValue, which I sent to the page in a querystring.
Getting it is no problem but how do I select that row based on the value, i.e. how to do:
RadGrid1.SelectedValue = queryStringValue;
Best,
Richard
0

Shinu
Top achievements
Rank 2
answered on 05 Oct 2010, 07:16 AM
Hi Richard,
In ItemDataBound event of the grid, check for the DataKeyValue and select the corresponding row.
Code behind:
Hope this helps,
Shinu.
In ItemDataBound event of the grid, check for the DataKeyValue and select the corresponding row.
Code behind:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
if
(item.GetDataKeyValue(
"CustomerID"
).ToString() == queryStringValue)
{
item.Selected =
true
;
}
}
}
Hope this helps,
Shinu.
0

Richard Weeks
Top achievements
Rank 2
answered on 06 Oct 2010, 07:27 AM
Hi, thanks for sticking with me :)
Your solution will work, I think.
But I realised I needed something more complicated (I have multiple parent / child grids), so I am putting the values into session variables and then checking for them in the destination page.
I haven't quite worked out what I do next but that's another story!
Wouldn't it be nice to just have a set accessor on SelectedValue?
Richard
Your solution will work, I think.
But I realised I needed something more complicated (I have multiple parent / child grids), so I am putting the values into session variables and then checking for them in the destination page.
I haven't quite worked out what I do next but that's another story!
Wouldn't it be nice to just have a set accessor on SelectedValue?
Richard