开发者

DetailsView control ObjectDataSource parameterized select Issue

开发者 https://www.devze.com 2023-01-23 12:58 出处:网络
I\'m using a GridView and Details View and my datasource is a custom ObjectDataSource that returns a DataSet.

I'm using a GridView and Details View and my datasource is a custom ObjectDataSource that returns a DataSet.

This isn't a SQL server, I'm using an LDAP query to get users from Active Directory.

I have two custom datasources in the ASPX page with one bound to the GridView and one to the DetailsView. They both have SelectMethods and Parameters that work.

The GridView works perfectly. When I run the query against the Active Directory, I get my list of people in the GridView with an autogenerated select link. I can click on this link and it passes whichever value I want via the DataKeyNames to the SelectedIndexChanged event.

What I'm doing in this event is setting the parameter for the ObjectDataSource for the DetailsView control. It does call into the custom class and return back a DataSet that contains ONE USER.

What's interesting here is that when I setup this ObjectDataSource in the ASPX page, I give it a Default parameter value. When the page loads, the DetailsView control shows up with the values returned via the default parameter.

So...I know this works to some degree.

However, when I set the开发者_StackOverflow社区 parameter in the SelectedIndexChanged event for the GridView, the select method in the custom class runs and returns the proper DataSet, but the DetailsView control is not updated with the new information.

Here's the ASPX code for ObjectDataSource for the DetailsView:

<asp:ObjectDataSource ID="_prvODSDetailsView" 
                  SelectMethod="_pubGetSingleUserDataSetByKerberosID"
                  TypeName="NotImportant"
                  runat="server">
   <SelectParameters>
  <asp:Parameter Direction="Input" Name="param_KerberosID" Type="String" DefaultValue="somedefaultvalue" />
   </SelectParameters>
</asp:ObjectDataSource>  

Here's my DetailsView code:

<asp:DetailsView ID="_prvDetailsViewShown" 
          CssClass="detailgrid"
          GridLines="None"
          DefaultMode="Edit"
          EmptyDataText="<No Details Available>"
          AutoGenerateRows="true"
          DataKeyNames="KerberosID"
          DataSourceID="_prvODSDetailsView"
          Width="100%"
          runat="server">
</asp:DetailsView>

Just to reiterate. This works on the first page load using the default value from the parameter.

void _prvGridView_SelectedIndexChanged( object sender, EventArgs e )
{
    DataKey k = _prvGridView.SelectedDataKey;
    string kerberosID = k.Value.ToString();
    Parameter parameter = new Parameter( "param_KerberosID", TypeCode.String, kerberosID );
    _prvODSDetailsView.SelectParameters[ 0 ] = parameter;
}

What I'm expecting to happen is the binding occurs and the control gets automatically updated. In fact, I'm pretty sure the DetailsView binding does occur, but the control never gets updated.

What am I missing?


Well, I found the answer. My GridView is in an UpdatePanel (ASP .NET AJAX) and the DetailsView as not. Apparently, you can't have that.

When removed all of the AJAX components, it worked.

When I put the DetailsView in the SAME UpdatePanel as the GridView, it also worked.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号