GridView DataKey

M

Mark Richards

I posted this earlier, and got no response. Basically I need to be able to
grab a value from one of the fields in a gridView to populate a dropdown in
another column of the gridview:


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,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top