Hi,
I am facing Combobox Bind issue in grid while using custom template in editmode,
table data comes to datatable but while providing datasource it gives error.
Thanks
I am facing Combobox Bind issue in grid while using custom template in editmode,
table data comes to datatable but while providing datasource it gives error.
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditableItem)
{
GridEditableItem edit = (GridEditableItem)e.Item;
RadComboBox cmbUserType = (RadComboBox)edit.FindControl("cmbusertype");
DataTable dt1 = ObjGlobas.UserType();
cmbUserType.DataSource = dt1;
cmbUserType.DataTextField = "UserType";
cmbUserType.DataValueField = "UserTypeId";
cmbUserType.DataBind();
}
}
5 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 27 Nov 2013, 06:52 AM
Hi Swapnil,
I guess you want to bind the RadComboBox in editmode. Please use the following if condition when the Grid is in editmode:
C#:
Thanks,
Princy
I guess you want to bind the RadComboBox in editmode. Please use the following if condition when the Grid is in editmode:
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode )
{
GridEditableItem edit = (GridEditableItem)e.Item;
RadComboBox cmbUserType = (RadComboBox)edit.FindControl(
"cmbusertype"
);
DataTable dt1 = ObjGlobas.UserType();
cmbUserType.DataSource = dt1;
cmbUserType.DataTextField =
"UserType"
;
cmbUserType.DataValueField =
"UserTypeId"
;
cmbUserType.DataBind();
}
}
Thanks,
Princy
0
Swapnil
Top achievements
Rank 1
answered on 27 Nov 2013, 07:13 AM
Hi,
i am using custom template for insert and automatic editmode for update
i want to bind the db output to combobox in custom template for insert(see attached images)
and datatable also has value but during bind it gives error
Thanks
i am using custom template for insert and automatic editmode for update
i want to bind the db output to combobox in custom template for insert(see attached images)
and datatable also has value but during bind it gives error
Thanks
0
Accepted
Princy
Top achievements
Rank 2
answered on 27 Nov 2013, 07:32 AM
Hi Swapnil,
Please use GridEditFormInsertItem, when the Grid is in Insert-mode.
C#:
Thanks,
Princy
Please use GridEditFormInsertItem, when the Grid is in Insert-mode.
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditFormInsertItem)
{
GridEditFormInsertItem insert = (GridEditFormInsertItem)e.Item;
//Your code
}
}
Thanks,
Princy
0
Swapnil
Top achievements
Rank 1
answered on 27 Nov 2013, 08:00 AM
Thanks
but inside if condition only one combo fills up and it gives same error for second combo though the data can be seen in datatable.
Why this is happening?
but inside if condition only one combo fills up and it gives same error for second combo though the data can be seen in datatable.
Why this is happening?
0
Swapnil
Top achievements
Rank 1
answered on 27 Nov 2013, 08:13 AM
Solved it ,
i just used column name cmbCompanyName rether than cmbcompanyname
Big Thanks To You
Thanks
i just used column name cmbCompanyName rether than cmbcompanyname
Big Thanks To You
Thanks