This is a migrated thread and some comments may be shown as answers.

Cannot Select row.

11 Answers 406 Views
Grid
This is a migrated thread and some comments may be shown as answers.
hosam dahhan
Top achievements
Rank 1
hosam dahhan asked on 17 Apr 2010, 10:11 AM

Hello I got this problem yesterday at work, and i worked few extra hours to solve it and I couldn't, please read the following scenario. 
 
1-a radgrid with multiselection rows set to "false", a button to modify and another to add data to the grid, all(2 buttons and the radgrid) exist in the same UpdatePanel(the classical one),  
 
2-the user will select a row,press the modify button, a rad window will open(using radwindow and radwindowmanager

(note: i tried to place the rad windowmanager is outside and inside the update panel , and i also tried to remove the whole updatepanel)
 
3- radwindow property to postback the parent page after closing it is set to "true". when the user saves his changes using the save button in the radWindow, the changes is saved successfully. and for more insuring; after the modification done successfully and before closing the rad grid, the parent page is forced to be refreshed using JavaScript, the same function that is used in telerik forum. 
 
so the parent page is refreshed twice , one after the modifications is completed, and another after closing the radwindow. 
 
the problem is after the rad window is closed, the radgrid selected index change event doesn't always  fire when selecting a row and if it does,  an out of index exception is fired because the count of the selected rows is Zero !! so the event is fired , but no row is selected inside the code.
 
and another question. isn't there any direct way to know the selected index immediately when multirow selection is set to "false".?

11 Answers, 1 is accepted

Sort by
0
hosam dahhan
Top achievements
Rank 1
answered on 19 Apr 2010, 12:25 PM
so any suggestion?
0
hosam dahhan
Top achievements
Rank 1
answered on 19 Apr 2010, 01:45 PM
so, am I being ignored or what? if more clarification is needed just ask for it ....
0
Veli
Telerik team
answered on 20 Apr 2010, 05:20 PM
Hello hosam,

If I understand you correctly, you are rebinding the RadGrid in the parent page when the window is closed. If this is the case, note that the selected items are not persisted when the grid is rebound. If you are trying to access the selected item after RadGrid is rebound, this explains why it is null. Otherwise, with single row selection, RadGrid.SelectedItems[0] always gives you the single selected item.

All the best,
Veli
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
hosam dahhan
Top achievements
Rank 1
answered on 21 Apr 2010, 07:25 AM
Dear Veli 

  actually this is not the case, the selected index before opening the radwindow is not my concern, the problem is that when i close the the rad window and refresh the parent page, an exception is fired when i select any other row. anyway i will send u today with a formal ticket a sample project.

Thanks.
0
Veli
Telerik team
answered on 21 Apr 2010, 10:10 AM
Hi hosam,

All right. Looking forward to your ticket. Please mention this forum thread inside, so that the  ticket can be routed through.

Greetings,
Veli
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
hosam dahhan
Top achievements
Rank 1
answered on 21 Apr 2010, 03:40 PM
hello again

 I have got my sample back working using needDataSource event and 

      <script language="javascript" type="text/javascript">
         function PostCloseAction() {
             //__doPostBack();
             $find("gvAttributes").get_masterTableView().rebind();
         }
      </script>
but when i tried in my project, i got the following Javascript error in this line
    $find("gvAttributes").get_masterTableView().rebind();

which was  " 'null' is null or not an object"

what can i do solve this? knowing that the scriptmanager is on the masterpage....?!
0
Veli
Telerik team
answered on 22 Apr 2010, 03:22 PM
Hello hosam,

This is because in a master/content page scenario you need to access the client ID of your server controls with some binding expressions. Simply replace the code you posted here with:

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script language="javascript" type="text/javascript">
    function PostCloseAction() {
     //__doPostBack();
     $find("<%= gvAttributes.ClientID %>").get_masterTableView().rebind();
    }
</script>
</telerik:RadCodeBlock>

Here is more info on RadCodeBlock. This should work for you now.

Sincerely yours,
Veli
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
hosam dahhan
Top achievements
Rank 1
answered on 22 Apr 2010, 08:20 PM
well the rad window is not opening anymore , and when i added the OnNeedDataSource event i really can't get the scenario...

correct if i'm wrong..

i have removed all the (RADGRID.DATASOURCE AND RADGRIRD.DATABIND()) from my code, whether it was on page_load, pageindexchanged or cleargrid..... then i added the onNeedDatasource event.with Gridview.datasource =dataset, as i fill the dataset in the page_load event.....

now the radgrid doesn't bind on all events, plus the rad window is not showing.... although its code is executed....
0
Veli
Telerik team
answered on 23 Apr 2010, 11:07 AM
Hi hosam,

Is the NeeddataSource event firing? Also, note that you are creating all your column dynamically on every postback, so I moved the method call to get the data and create the grid column on top in Page_Load. Did you test the example I have attached as a reply to your support ticket? Can you point out if  you have made any modifications to its example. You can also send an updated example showing your progress on this.

Sincerely yours,
Veli
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
hosam dahhan
Top achievements
Rank 1
answered on 23 Apr 2010, 05:07 PM
helllo

the example that u have sent worked perfectly....but in my project, the dataset is filled on page_load. so i used to bind the grid there, and also page index event. so from what i understood from OnNeedDataSource event is that i have to remove the the gridview bingind method and gv.datasource event from page load and page index event then add GV.DATASOURCE= the dataset filled in the page load. the radwindow isnot working and i can't really understand when the bind happens. but it the onNeedDatasource does fire, but i just don't know how to use it really....the example i sent is very simple, in the project its really hard to send an example with same scenario.....
0
Veli
Telerik team
answered on 26 Apr 2010, 07:32 AM
Hi hosam,

Here are a couple of help articles that I believe are related to your scenario. I hope they can shed some light on the initialization and binding requirements for RadGrid.

RadGrid Programmatic Creation

RadGrid Advanced Databinding (using NeedDataSource)


Greetings,
Veli
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
hosam dahhan
Top achievements
Rank 1
Answers by
hosam dahhan
Top achievements
Rank 1
Veli
Telerik team
Share this question
or