I'm using a gridview with paging. My grid has a command column and ShowSelectCheckbox
is set to true. I bind DataTable
to grid at Page_Load
event with the condition [ if (!IsCallback)
].
So when i change page index data is lost. After that i wrote bind code to grid's PageIndexChanged
event. Now it works like charm.
But GetSelectedFieldValues
works only at first page when SelectionChanged
event occurs.
In example when i select a row at first page it gets the field values that i want. But when i change pageindex GetSelectedField
cannot get the field values. It alerts empty text.
If i select a row at second page index it works at that page too, but when i change page index it's broken again.
BTW it works when i bind the grid at PageLoad
event without !IsCallback
condition but i can't bind it at Page_Load
event because of other controls must have to change the query and so data.
Here goes my javascript function which alerts selected values
<ClientSideEvents SelectionChanged="function(s, e) {
grid.GetSelectedFieldValues('SDNO;SANTRAL',alert);
}" />
And page index changed event
protected void myGrid_PageIndexChanged(object sender, EventArgs e)
{
myGridDataSource = dtable; //dtable is static, i also used BindThat function here too. But no way out.
myGridDataBind();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsCallback)
{
BindThat(); // Fetch data from db, create dtable and bind it to grid.
}
}
Best Answer
I think this is not the correct way to get the values from the grid at client side, check the following link: http://www.devexpress.com/Support/Center/p/Q94237.aspx
Question: is your grid support multiple selection?
Edit1: Check the following Examples as well:
How to use a GetSelectedFieldValues method to obtain values of several columns at once
How to get the values of the selected record from the server