I try to find the event where to reset Aspxgridview pageindex = 0 on
http://www.devexpress.com/Support/Center/p/Q207278.aspx i found plato suggestion that i need to put pageindex reset on Page_LoadComplete
Protected Sub Page_LoadComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadComplete
gridaddmovies.PageIndex = 0
The problem is that this solve one problem (so for example if i search for hitman and then i search for rambo i will get to the first rambo result page) but this create another problem the chechbox for select working only on first result page for other page when i select item there is no selected item in listbox from gridview.
Also if i select any item on first page and try to change theme or search another query i get Input string was not in a correct format error
Please look my sample project in attachment.
Basically i need to do this:
1 Each time user perform a search display first result page
2 when user check/uncheck some item on page display/remove it from listbox
3 if some item are checked, change theme or make new query with no error
Can you help me?
Run the sample project
1 On textbox type hitman click on search check the first item then try change theme
Error = Input string was not in a correct format
2 On textbox type hitman click on search check the first item then on textbox type rambo and click search
Error = Input string was not in a correct format
3 On textbox type hitman click on search check the first item on second page scroll down to listbox
Error = there is no selected item on listbox
All 3 error are related to gridaddmovies.PageIndex and gridaddmovies.Selection.
If i don't set gridaddmovies.PageIndex = 0 on Page_LoadComplete then when a query change the pageindex is set on preview query index
for example the first query is hitman the second is rambo. To reproduce this comment gridaddmovies.PageIndex = 0 On textbox type hitman click on search click on last page 56 on textbox type rambo click search you will see page 12 (the last page of rambo query)
So i need a way to reset PageIndex and show 1 page for each query. When i put gridaddmovies.PageIndex = 0 on Page_LoadComplete i get the first result for each query but also i can't get selected item from any other then first page in listbox
On textbox type hitman click on search check the first item on second page scroll down there is no selected item in listbox
How can i fix this 3 error?
We've reproduced all problems.
The first two may be solved by replacing the selList.AddItem(values[i], values[i]) with selList.AddItem(values[i], values[i]).
The third problem isn't solved yet. We're currently working on a solution and will answer you as soon as it is found.
The third issue is caused by the fact that you clear the selection via the gridaddmovies.Selection.UnselectAll() method, which is called in the gridaddmovies_PageIndexChanged event handler.
You can solve this problem by resetting the PageIndex by clicking the Search button:
Protected Sub gridaddmovies_PageIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles gridaddmovies.PageIndexChanged newindex = gridaddmovies.PageIndex + 1 gridaddmovies.DataBind() End Sub Protected Sub Page_LoadComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadComplete End Sub Protected Sub btnsearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnsearch.Click gridaddmovies.Selection.UnselectAll() gridaddmovies.PageIndex = 0 newindex = gridaddmovies.PageIndex + 1 gridaddmovies.DataBind() End Sub
Please also note that the current selection will show only selected data on the current page.
I try make changes like in your sample code but now the parameter title and image is empty to be clear i get only the asin value with selList.AddItem(values[i], values[i], values[i]);
To reproduce this run the sample project.
On textbox type hitman select the first two result scroll down and on combobox select list1 then click on add selected button. I put msgbox on ASPxCallbackPanel1_Callback to see the value i get. The value pars(0) is reserved for addselected, pars(1) is reserved for idlist and in the other pars value i expect 3 parameter title,asin,image.
How can i get this parameter?
In old code selList.AddItem(values[i], values[i], values[i]); i get this 3 parameter in format title,asin,image but title can have inside , character so i can't use this for parse.
Can you advice me a better solution?
In this situation I suggest that you change the logic as follows:
1) Save selection to the listbox
On the click of the "Add selected" button:
2) Send an "empty" callback from the ASPxCallbackPanel
3) Get saved selection on the server side, get required values and save them
4) Send a callback from the ASPxGridView and clear the selection.
I've modified your sample according to this solution and attached it.