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

problem accessing nested grid values

2 Answers 87 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Silver
Top achievements
Rank 1
Silver asked on 06 Sep 2011, 09:52 AM
i have grid2 & btnUpdate inside grid1 "MasterTableViewEditForms" (Template)
and i've successfully bind grid2 datasource inside grid1
my problems is, i can't get values from grid2 when hitting btnUpdate

Protected Sub grid1_UpdateCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles grid1.UpdateCommand
    Dim grd2 As RadGrid = TryCast(TryCast(e.Item, GridDataItem).ChildItem.FindControl("grid2"), RadGrid)
    lblMsg.Text = grd2.Items(0).Cells(2).Text
End Sub

the following error occured when hitting btnUpdate "Object reference not set to an instance of an object."

i have search some post in this forums but couldn't find any solution, please help
thanks in advance.

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 06 Sep 2011, 01:43 PM
Hello Silver,

I suppose you need access the grid2 on button click.Try the following code snippet.
C#:
protected void grid1_UpdateCommand(object sender, GridCommandEventArgs e)
 {
   GridEditFormItem item = e.Item as GridEditFormItem;
   RadGrid grid = (RadGrid)item.FindControl("grid2");
 }

Thanks,
Shinu.
0
Silver
Top achievements
Rank 1
answered on 07 Sep 2011, 02:41 AM
thanks shinu, your solution work well
Tags
Grid
Asked by
Silver
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Silver
Top achievements
Rank 1
Share this question
or