Radgrid inside editform settings

2.3k views Asked by At

I have a radgrid inside the edit form.I am binding the radgrid on the itemdatabound.

        int id= Convert.ToInt32(editForm.GetDataKeyValue("ID").ToString());
        RadGrid SummaryGrid = (RadGrid)item.FindControl("SummaryGrid");
        SummaryGrid.DataSource = spObj.Sp_GetProjectDetails(id);
        SummaryGrid.Visible = true;
        SummaryGrid.Enabled = true;
        SummaryGrid.DataBind();

The problem is I am able to edit only the last row in the grid.I m able to see the data binding to the inner grid for the last row.For all other rows I get the below error.

"There was a problem extracting DataKeyValues from the DataSource. Please ensure that DataKeyNames are specified correctly and all fields specified exist in the DataSource."

My grid inside edit:

     <telerik:RadGrid ID="SummaryGrid" runat="server" AllowPaging="True" PageSize="50"      AutoGenerateColumns="true"   Visible="true"   
 AllowMultiRowSelection="true" AllowSorting="true" Skin="Hay" Width ="500px" >
  <MasterTableView  DataKeyNames="ProjectID"  CommandItemDisplay="Top"      TableLayout="Fixed" Caption ="Position-Specific Network + Activity Code Totals"  Font-Bold="true" Font-Size="Small" Font-Names ="Ericsson Capital TT" >
   <PagerStyle Mode="NumericPages" Position="Top"></PagerStyle>
 <CommandItemSettings ShowAddNewRecordButton="false"/>
  </MasterTableView></telerik:RadGrid>
 </telerik:RadAjaxPanel>

This issue is blocking the development.can some one suggest any help on this?Any help/ideas highly appreciated.

Thanks

1

There are 1 answers

0
dst3p On

int id= Convert.ToInt32(editForm.GetDataKeyValue("ID").ToString());

This should be using ProjectID instead of ID. ID is not a data key that you've specified in your MasterTableView.