This is a migrated thread and some comments may be shown as answers.

Not able to pass object property (datakey) runtime to source of Detailview

1 Answer 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
naimish
Top achievements
Rank 1
naimish asked on 05 Oct 2010, 07:17 AM
Hi all,

I have radgrid with nested detail view, detail view uses object datasource.
The input method of obect data source (SelectMethod)  accepts object as input paraemeter on
OnSelecting event.

Now iam gettting Datakey value in ItemCommand event, when user hits the expand button, 
but not able to pass this kayvalue as input parameter in OnSelecting event of objectdatasource due to both events fire at different post.
How can i paas objects property (Datakey i.e EmpId) runtime to detailview of radgrid.

something like this...
input object as a parameter to object datasource
Class Employee
{
   EmpId=0;
   EmpName="";
   Age="";
   

}

<asp:ObjectDataSource ID="ObjectDataSource" runat="server" SelectMethod="GetEmpTicketDetails"
                                                TypeName="EmployeeRecordSOAP" OnSelecting="ObjectDataSource_Selecting"
                                                OnObjectCreating="ObjectDataSource_Creating">
                                                <SelectParameters>
                                                     
                                                   
                                                <asp:Parameter  Type="Object" Employee" DefaultValue="null"  />
                                                   
                                                </SelectParameters>

protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
            EmpInputParams obj = new EmpInputParams();
            EmpID = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["EmpId"].ToString();   
      
        }

protected void ObjectDataSource_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
        {
        
          EmpInputParams obj = new Diebold.SERAS.Controls.AdvisorWS.EmpInputParams();
          obj.EmpId=-1;
          obj.EmpName="";  
          e.InputParameters["obj"] = obj;        
     
        }




1 Answer, 1 is accepted

Sort by
0
Accepted
Vasil
Telerik team
answered on 08 Oct 2010, 09:06 AM
Hi naimish,

Thank you for contacting us and for your question.

You should set ParentTableRelation for the DetailTables, which define the relation between the data in the master and detail view. Also make sure to set SelectParameters in the object data source for the detail table. For additional help read this help topic.

The GridView will automatically load needed data when expanded, and you do not need care about  ItemCommand and Selecting events. Check the following attached demo. And if you are unable to resolve the issue, open a formal support ticket, and send us your code with the declaration of the grid and datasources.

Kind regards,
Vasil
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
naimish
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Share this question
or