madpul 0 Newbie Poster

Hi guys,
I am getting the following error on trying to find out the selected composite primary key in gridview
ERROR : Expecting 2 value(s) for the key being indexed, but received 1 value(s).

Code here:

The code for binding

if (dsetData.Tables[0].Rows.Count > 0)
{
DataColumn[] col=new DataColumn[2];
DataColumn col1 = dsetData.Tables[0].Columns["customer_no"];
DataColumn col2 = dsetData.Tables[0].Columns["document_no"];
col.SetValue(col1, 0);
col.SetValue(col2, 1);
dsetData.Tables[0].Constraints.Add("pkData", col, true);
gdvCustDocs.DataSource = new DataView(dsetData.Tables[0]);
gdvCustDocs.DataBind();
}

Here is the code for which i used in the gridview selectedIndexChanged Event

int[] bc=new int[2];
int b1, b2;
b1 = Int32.Parse(gdvCustDocs.SelectedDataKey.Values[0].ToString());
b2 = Int32.Parse(gdvCustDocs.SelectedDataKey.Values[1].ToString());
bc.SetValue(6, 0);
bc.SetValue(7, 1);
DataRow drow = dsetData.Tables[0].Rows.Find(bc);  // This is where I am getting above mentioned Error

Here is the gridview code
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
<ContentTemplate>
<asp:Button Visible="false" ID="btnFetchCustDocs" runat="server" Text="Fetch Customer Documents" onclick="btnFetchCustDocs_Click" />
<asp:GridView ID="gdvCustDocs" runat="server" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="customer_no,document_no" ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="gdvCustDoc_SelectedIndexChanged" align="center" class="gridView">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:CommandField ButtonType="Button" ShowSelectButton="True" />
<asp:BoundField DataField="customer_no" Visible="false" HeaderText="First Name" SortExpression="customer_no" />
<asp:BoundField DataField="document_no" Visible="false" HeaderText="First Name" SortExpression="document_no" />
<asp:BoundField DataField="Document_Type" HeaderText="Document Type" SortExpression="Document_Type" />
<asp:BoundField DataField="Document_Name" HeaderText="Document Name" SortExpression="Document_Name" />
<asp:BoundField DataField="File_Type" HeaderText="File Type" SortExpression="File_Type" />
<asp:BoundField DataField="File_Name" HeaderText="File Name" SortExpression="File_Name" />
<asp:BoundField DataField="File_URL" HeaderText="File URL" SortExpression="File_URL" />
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
<asp:Label ID="Label1" Text="" runat="server"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>