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

Using edit instead of hierarchy and some questions

3 Answers 49 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Laura
Top achievements
Rank 1
Laura asked on 03 Sep 2008, 06:20 PM
I have decided to use the edit form and embed a child grid inside rather than use hierarchy. This is my setup:

Provider table and each provide can have one or more contacts.

My main page lists providers, and when I click to edit (or insert) a provider, one of the controls in the form is a subgrid of the contacts. In order to do this, I need to know what the current selected provider is. How can I set or get a variable that would contain the current provider_id and use this in my select statement for the contact table?

Thanks,
Laura

3 Answers, 1 is accepted

Sort by
0
andy
Top achievements
Rank 1
answered on 03 Sep 2008, 06:25 PM

Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles RadGrid1.ItemDataBound


If

e.Item.IsInEditMode Then

 

Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)

MsgBox(editedItem(

"myID").Text)

End if
End Sub

0
Laura
Top achievements
Rank 1
answered on 03 Sep 2008, 07:12 PM
Thank you....

Is there any way to get this info in aspx to use in the selectcommand?

Thanks
0
andy
Top achievements
Rank 1
answered on 03 Sep 2008, 07:22 PM
Hmm.. not the best way but dynamically change ur selectcommand?

Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles RadGrid1.ItemDataBound   
 
If e.Item.IsInEditMode Then   
 
Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)  
 
dim parameter as string = editedItem(  
 
"myID").Text)   
 
Dim sqldata as sqldatasource = CType(editedItem.FindControl("sqldatasource1"), sqldatasource)  
 
Dim ChildGrid As RadGrid = CType(userControl.FindControl("ChildGrid"), RadGrid)  
 
sqldata.selectcommand = "select ... = " + parameter  
 
ChildGrid.rebind()  
 
End if  
End Sub  
 


Tags
Grid
Asked by
Laura
Top achievements
Rank 1
Answers by
andy
Top achievements
Rank 1
Laura
Top achievements
Rank 1
Share this question
or