Hi, How do u do selectparameter at the back end code?
I am facing this problem of the gridview not being able to find the datasource in the accordionpane so i decided to move the datasource out of the accordionpane.
However, since the gridview's datasource is linked to another gridview in the accordionpane, I will need to do a selectParameter to connect both gridviews.
The gridview using the datasource is called basicBookDetails.
The gridview to be linked with basicBookDetails is called book.
Book_List_ID is the datakeynames for both gridview book and basicBookDetails.
Can someone help me with this problem? Thanks.
This is the query statement that I used.
SELECT book_details.Status, book_list.Book_List_ID, Circulation_Type, book_details.Book_Details_ID, CONCAT(rockwell.book_list.Title, IFNULL(CONCAT(', ', edition.Edition_Name), ' ')) AS Title FROM book_list, edition, book_details, circulation_type WHERE (edition.Edition_ID = book_details.Edition_ID) AND (circulation_type.Circulation_ID = edition.Circulation_ID) AND (edition.book_list_id = book_list.Book_List_ID) AND (book_list.Book_List_ID = ?)
Hi There,
You can actually set your datasource select statement parameter on code-behind like below:
on your code behind, get the Book_List_ID and set it to your datasource
basicBookDetails.SelectParameters[0].DefaultValue ="YourParameterHere";
Hope this is help
|||Hi,
Do you mind explaining a bit about what u said as I am a bit lost.
Am I also supposed to do changes to the query also after I add in the select statement parameter?
Do I need to declare a new parameter to input in the "YourParameterHere" or do i directly use Book_List_ID and place it inside?
Thanks.
|||Hi There,
Correct me if im wrong, I guess you are doing something like Master / Detail with Gridview ?
So when you expand the detail, you set the parameter for the particular selected row so that it returns the correct value for the detail.
"Am I also supposed to do changes to the query also after I add in the select statement parameter?"
You don't need to change the query
"Do I need to declare a new parameter to input in the "YourParameterHere" or do i directly use Book_List_ID and place it inside?"
You do not need to declare new paramter, just set whatever value you get from the master in this case Book_List_ID
|||The first gridview has a link button which is used to link to the 2nd gridview.
Meaning that gridview 1 is the master and gridview 2 is the details page and they are linked through datakeynames book_list_id.
I've gotten an exception when i run the page.
The exception is : "Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index "
Do you have any idea what it means?
|||Hi There,
Could you show me your code here ? curious how is your sqldatasource look like.
Seems that your sqldatasource do not have insert parameter
e.g.
<SelectParameters>
<asp:ParameterName="book_list_id"Type="Int32"/>
</SelectParameters>
|||This is my sqldatasource
<asp:SqlDataSourceID="bookExtensionDataSource"
runat="server"
ConnectionString="<%$ ConnectionStrings:rockwellConnectionString %>"
ProviderName="<%$ ConnectionStrings:rockwellConnectionString.ProviderName %>"
SelectCommand="SELECT book_details.Status, book_list.Book_List_ID, Circulation_Type, book_details.Book_Details_ID, CONCAT(rockwell.book_list.Title, IFNULL(CONCAT(', ', edition.Edition_Name), ' ')) AS Title FROM book_list, edition, book_details, circulation_type WHERE (edition.Edition_ID = book_details.Edition_ID) AND (circulation_type.Circulation_ID = edition.Circulation_ID) AND (edition.book_list_id = book_list.Book_List_ID) AND (book_list.Book_List_ID = ?)">
<SelectParameters>
<asp:ControlParameterControlID="book"Name="?"PropertyName="SelectedValue"/>
</SelectParameters>
</asp:SqlDataSource>
book is the ID of the master gridview(gridview 1)
|||This is my sqldatasource
<asp:SqlDataSourceID="bookExtensionDataSource"
runat="server"
ConnectionString="<%$ ConnectionStrings:rockwellConnectionString %>"
ProviderName="<%$ ConnectionStrings:rockwellConnectionString.ProviderName %>"
SelectCommand="SELECT book_details.Status, book_list.Book_List_ID, Circulation_Type, book_details.Book_Details_ID, CONCAT(rockwell.book_list.Title, IFNULL(CONCAT(', ', edition.Edition_Name), ' ')) AS Title FROM book_list, edition, book_details, circulation_type WHERE (edition.Edition_ID = book_details.Edition_ID) AND (circulation_type.Circulation_ID = edition.Circulation_ID) AND (edition.book_list_id = book_list.Book_List_ID) AND (book_list.Book_List_ID = ?)">
<SelectParameters>
<asp:ControlParameterControlID="book"Name="?"PropertyName="SelectedValue"/>
</SelectParameters>
</asp:SqlDataSource>
book is the ID of the master gridview(gridview 1). i am trying to move the select parameter to the back end as it seems that the gridview cannot detect the datasource in the accordionPane.
|||Hi There,
Are you doing something like, you have a master gridview, each master row have accordian and expand accoridian and display the detail ? like follow ?
Master
-- Accordian
-- Detail ?
Try this, i think this is better module:http://www.codeproject.com/aspnet/MasterDetail.asp
|||
The sequence of flow is like this
Accordion
--->master
---->details
---->details
Hi There,
Did you try out the link that i posted ?
Unfortunately, im at work can;t actually write a sample to test your scenario now. Will try do it later tonight.
;)
|||
Hi there,
Would you able to post your code here? i think this would be better rather than i create a test that is not relavant to yours.
shacky:
The sequence of flow is like this
Accordion
--->master
---->details
---->details
The above structure is a bit weird to me, is there a specific reason ?
|||All the gridviews are actually within an accordionPane.
When the master gridview is selected, the relevant information will be displayed in gridview 2(1st detail).
When gridview 2 is selected(1st detail) is selected, the relevant information will be displayed in gridview 3(2nd detail).
Below is the selectparameter for gridview 2 and 3:
selectparameter of gridview 2
<SelectParameters>
<asp:ControlParameterControlID="book"Name="?"PropertyName="SelectedValue"/>
</SelectParameters>
selectparameter of gridview 3
<SelectParameters>
<asp:ControlParameterControlID="basicBookDetails"Name="?"PropertyName="SelectedValue"/>
</SelectParameters>
No comments:
Post a Comment