|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Strange behavior with gridview and selectedindexI have an asp.net 2.0 web app that uses gridview and formview. When a user selects an item in the gridview the formview appears to show the detail. This works quite well. However, I'd also like the formview to be displayed if a specific datakey for an item in the gridview is passed through the querystring. I have the following code in place on the page_load event to handle this: If Not String.IsNullOrEmpty(Request.QueryString("funding_request_id")) Then sqlPACE.SelectCommand = sqlPACE.SelectCommand.Insert(sqlPACE.SelectCommand.IndexOf("ORDER BY"), " WHERE funding_request_id=" & Request.QueryString("funding_request_id") & " ") gvFRequests.SelectedIndex = 0 'Threading.Thread.Sleep(10000) Dim orig As New WebControls.CommandEventArgs("Select", gvFRequests.SelectedIndex) Dim args As New WebControls.GridViewCommandEventArgs(gvFRequests, orig) gvFRequests_RowCommand(gvFRequests, args) End If When I run this, the gridview correctly shows just the one row selected, but doesn't display the formview. HOWEVER, if I place a breakpoint in the page_load event, the formview appears after I continue the execution! Remove the breakpoint and the formview will not be displayed. As you can see, I tried "sleeping" the thread to see if that would do it, but it doesn't work. Any ideas? If the declarative syntax for the datasource object contains a
ControlParameter to access the selectedvalue of the GridView, e.g. <SelectParameters> <asp:ControlParameter ControlID="ChildGridView1" Name="OrderId" PropertyName="SelectedDataKey.Values[0]" Type="Int32" /> </SelectParameters> Then it would override the code that you just did upon re-databinding. You might try in the codebehind to remove that ControlParameter and add a new one of type QueryStringParameter http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.querystringparameter.aspx Then call again the Select method of the datasource object. Show quoteHide quote "jordo" wrote: > Hello there, > I have an asp.net 2.0 web app that uses gridview and formview. When a user > selects an item in the gridview the formview appears to show the detail. > This works quite well. However, I'd also like the formview to be displayed > if a specific datakey for an item in the gridview is passed through the > querystring. > > I have the following code in place on the page_load event to handle this: > If Not > String.IsNullOrEmpty(Request.QueryString("funding_request_id")) Then > sqlPACE.SelectCommand = > sqlPACE.SelectCommand.Insert(sqlPACE.SelectCommand.IndexOf("ORDER BY"), " > WHERE funding_request_id=" & Request.QueryString("funding_request_id") & " ") > > gvFRequests.SelectedIndex = 0 > 'Threading.Thread.Sleep(10000) > Dim orig As New WebControls.CommandEventArgs("Select", > gvFRequests.SelectedIndex) > Dim args As New > WebControls.GridViewCommandEventArgs(gvFRequests, orig) > gvFRequests_RowCommand(gvFRequests, args) > > End If > > When I run this, the gridview correctly shows just the one row selected, but > doesn't display the formview. HOWEVER, if I place a breakpoint in the > page_load event, the formview appears after I continue the execution! Remove > the breakpoint and the formview will not be displayed. As you can see, I > tried "sleeping" the thread to see if that would do it, but it doesn't work. > Any ideas?
Master Detail Event Handling?
DataSourceID '<NewDataSource ...>' not working in composite contro Date masked textbox for user input ASP.NET 2.0 Databind during Client Callback Global Themes Folder Missing How to turn off padding within a Web Part? Problem with FindControl DropDown List Hide show asp table need help in web user control |
|||||||||||||||||||||||