When the user selects a row to edit I have a dropdownlist as one of the controls. In order for me to populate that ddl I need one of the datakeyname values (there are three). I was guessing that I could retrieve this value when the OnEditing event fired and pass it to the select statement for the ddl. Just not sure how to do this. I am using a stored procedure to query the Database.
This is my sqldatasource for the ddl –
<asp:SqlDataSource ID="SqlDataSourceDebtor" runat="server"
ConnectionString="<%$ ConnectionStrings:AuditDevConnectionString2 %>"
SelectCommand="sp_fc_vm_getDebtorList" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" DefaultValue="0" Name="ClientKey"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
The “ClientKey” is the datakeyname value I need.
There are multiple approach to do this, please check http://weblogs.asp.net/aghausman/archive/2009/01/08/get-primary-key-on-row-command-gridview.aspx
Let me know if you want anything specific other than this.