Rromero_Bolivia
unread,Jan 21, 2009, 9:53:08 AM1/21/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
you will need to add the dataKeyNames attribute
(DataKeyNames="ADDRESS_ID, CUSTOMER_ID") :
<asp:GridView ID="gvAddresses" runat="server"
AutoGenerateColumns="False" DataSourceID="sdsAddresses" ==>
DataKeyNames="ADDRESS_ID, CUSTOMER_ID" <== >
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="TYPE" HeaderText="TYPE"
SortExpression="TYPE" />
</Columns>
</asp:GridView>
Also change your source control to obtain the two values (edit your
SelectCommand):
<asp:SqlDataSource ID="sdsAddresses" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$
ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="SELECT [ADDRESS_ID],[CUSTOMER_ID], [TYPE] FROM
[ADDRESSES] WHERE ([CUSTOMER_ID]
= ?)">
then in your event you can retrieve this
protected void gvAddresses_SelectedIndexChanges(object sender,
EventArgs e)
{
DataKey data = gvAddresses.SeleectedDataKey;
string PrimaryKey = (string)data.Values["ADDRESS_ID"];
string ForeignKey = (string)data.Values["CUSTOMER_ID"];
}
I hope that works
_____________________