GridView DataKey

M

Mark Richards

I have a gridView that has 2 templated columns that contain drop-down lists. The first drop down list uses a value off of a formview on the same page for filtering. The 2nd drop-down is supposed to use the value off the first drop-down for it's parameter. I tried to add a parameter definition the same way I did referring to the FormView, but I get the following error:

DataBinding: 'System.Web.UI.WebControls.GridView' does not contain a property with the name 'DataKey'.

Offending Code:
<asp:ObjectDataSource ID="dsTarget" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetTargetsForSite" TypeName="AL.clsSite">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="SiteID" PropertyName="DataKey(&quot;SiteID&quot;)" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>



wheras this code works:

<asp:ObjectDataSource ID="dsSite" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetSitesForPublisher" TypeName="AL.clsSite">
<SelectParameters>
<asp:ControlParameter ControlID="FormView1" Name="PublisherID" PropertyName="DataKey(&quot;PublisherID&quot;)" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>





So, first, is this the best way to get a value out of a formView ? 2nd, how do I get a value from the GridView ?



Thanks,

Mark Richards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,817
Latest member
AdalbertoT

Latest Threads

Top