5 Answers, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 28 Jan 2011, 02:13 PM
Hello
You can either populate the RadComBoBox directly from aspx page. Or in ItemDataBound event of Radgrid access the Usercontrol in Edit form and then access the Combobox in UserControl. Then populate the control.
C#:
Hope this informtion helps,
-Shinu.
You can either populate the RadComBoBox directly from aspx page. Or in ItemDataBound event of Radgrid access the Usercontrol in Edit form and then access the Combobox in UserControl. Then populate the control.
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditFormItem && e.Item.IsInEditMode)
{
GridEditFormItem editItem = (GridEditFormItem)e.Item;
UserControl userControl = (UserControl)editItem.FindControl(
"GridUserControl1"
);
//accessing userControl
RadComboBox combo=(RadComboBox )userControl.FindControl(
"RadComboBox1"
);
//populate combo
}
}
Hope this informtion helps,
-Shinu.
0

Jonathan
Top achievements
Rank 1
answered on 01 Feb 2011, 11:59 PM
Ok,
But what if you're trying to bind the controls at design time IN the EditForm template to a field from the corresponding datasource control of the detail table? When I try to do that, all I'm seeing are the fields from the datasource control of the Master table. Why can't I see the fields from the datasource control of the detail table? (Its datasource property has already been set).
Thanks in advance.
John
But what if you're trying to bind the controls at design time IN the EditForm template to a field from the corresponding datasource control of the detail table? When I try to do that, all I'm seeing are the fields from the datasource control of the Master table. Why can't I see the fields from the datasource control of the detail table? (Its datasource property has already been set).
Thanks in advance.
John
0

Princy
Top achievements
Rank 2
answered on 02 Feb 2011, 10:15 AM
Hello John,
I am not quite sure about your issue. I guess you have a FormTemplate ( which containing RadComboBox) in DetailTable. And you want to populate it from aspx page using one of the fields in DetailTable DataSource. I have tried the similar scenario and it works at my end. Please take a look at the following code snippet.
ASPX:
Could you elaborate the issue if it doesn't help?
Thanks,
Princy.
I am not quite sure about your issue. I guess you have a FormTemplate ( which containing RadComboBox) in DetailTable. And you want to populate it from aspx page using one of the fields in DetailTable DataSource. I have tried the similar scenario and it works at my end. Please take a look at the following code snippet.
ASPX:
<
telerik:RadGrid
ID
=
"RadGrid1"
AutoGenerateColumns
=
"False"
runat
=
"server"
DataSourceID
=
"SqlDataSource1"
>
<
MasterTableView
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"EmployeeID"
UniqueName
=
"EmployeeID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"FirstName"
UniqueName
=
"FirstName"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
DetailTables
>
<
telerik:GridTableView
runat
=
"server"
DataSourceID
=
"SqlDataSource2"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"TerritoryID"
UniqueName
=
"TerritoryID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridEditCommandColumn
UniqueName
=
"detailEditColum"
>
</
telerik:GridEditCommandColumn
>
</
Columns
>
<
EditFormSettings
EditFormType
=
"Template"
>
<
FormTemplate
>
<
telerik:RadComboBox
ID
=
"RadComboBox1"
DataSourceID
=
"SqlDataSource2"
DataTextField
=
"TerritoryID"
DataValueField
=
"TerritoryID"
runat
=
"server"
>
</
telerik:RadComboBox
>
</
FormTemplate
>
</
EditFormSettings
>
<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"EmployeeID"
MasterKeyField
=
"EmployeeID"
/>
</
ParentTableRelation
>
</
telerik:GridTableView
>
</
DetailTables
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
asp:SqlDataSource
ID
=
"SqlDataSource1"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [EmployeeID],[FirstName] FROM [Employees]"></
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataSource2"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [EmployeeID],[TerritoryID] FROM [Territory] where EmployeeID=@EmployeeID">
<
SelectParameters
>
<
asp:Parameter
Name
=
"EmployeeID"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
Could you elaborate the issue if it doesn't help?
Thanks,
Princy.
0

Jonathan
Top achievements
Rank 1
answered on 02 Feb 2011, 07:44 PM
Ok, try this:
- Add a new form to a new project.
- Add a new DataSet to the project. The DataSet should include two tables that you can relate to each other with a foreign key.
- Add two ObjectDataSource objects to the form.
- Point one ObjectDataSource object to each table in the DataSet you created in step 2.
- Wire up the RadGrid as a Hierarchical grid, such that the MasterTableView uses ObjectDataSource1, and the Details view uses ObjectDataSource2.
- Click on the smart tag for the Rad Grid and select Edit Templates.
- Select the Details, bound to ObjectDataSource2editform template view from the Smart Tag.
- Drag a Literal onto the page (or any other bindable control for that matter).
- Use the smart tag on the newly added control to Edit Data Bindings.
- In the dialog that appears, you will need to hit the "Refresh Schema" link in order to select the list of fields from the Field Binding drop down list. You will find that only ObjectDataSource1 fields are available — even though you are editing the form template on the Detail TableView.
Let me know if you can recreate this issue.
Regards,
John.
0

Jonathan
Top achievements
Rank 1
answered on 25 Feb 2011, 08:53 PM
Ok. I got around this by typing in Eval("field_name") in the custom binding field.
I still think someone should look into why I have to use the Custom binding field instead of the Field Biding field to bind a control in an EditForm template of a detail tableview to a field from the datasource of the detail table. It should work just like it does for a Master Table field in a Master Table EditForm template.
Anyway, this is only a minor inconvenience. I'll work with typing in the binding in the Custom Binding field for now.
Regards,
John
I still think someone should look into why I have to use the Custom binding field instead of the Field Biding field to bind a control in an EditForm template of a detail tableview to a field from the datasource of the detail table. It should work just like it does for a Master Table field in a Master Table EditForm template.
Anyway, this is only a minor inconvenience. I'll work with typing in the binding in the Custom Binding field for now.
Regards,
John