I want to display RadCombobox in the RadGrid when insert/edit operations perform. I want to display list of values that binds from one of the column of another table.
Also whatever i am binding data from another table, it should save in Radgrid record which i am displaying.
4 Answers, 1 is accepted
You can use a RadComboBox in the EditItemTemplate of a TemplateColumn such that it displays in Edit/Insert mode of the grid. Also you can access the RadComboBox and set its DataSource to the required datatable.
If you want to display a datafield of another table in your grid, then you can use the Join clause which helps combine records from two tables in a database.
I configure in edittemplate but its not displaying combobox. Something goes wrong with my code.
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
AllowAutomaticUpdates="True" AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True"
<MasterTableView AutoGenerateColumns="False" CellSpacing="-1" CommandItemDisplay="Top"
<telerik:RadComboBox ID="RadComboBox1" runat="server" DataSourceID="SqlDataSource1"
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ResourceUtilizationDBConnectionString %>"
SelectCommand="SELECT [Division_ID], [Division_Name] FROM [NSS_Divisions]"></asp:SqlDataSource>
<telerik:GridBoundColumn DataField="Section_ID" DataType="System.Int32" HeaderText="Section_ID"
ReadOnly="True" SortExpression="Section_ID" UniqueName="Section_ID">
<telerik:GridBoundColumn DataField="Section_Name" HeaderText="Section_Name" SortExpression="Section_Name"
<telerik:GridBoundColumn DataField="Divsion_ID" DataType="System.Int32" HeaderText="Divsion_ID"
</telerik:RadGrid><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ResourceUtilizationDBConnectionString %>"
SelectCommand="SELECT * FROM [Division_Sections]"></asp:SqlDataSource>
You have added EditItemTemplate to MasterTableView which is why the RadComboBox does not appear on the Grid , instead add a GridTemplateColumn to the column collection of the MasterTableView and then you can add RadComboBox to the EditItemTemplate of the GridTemplateColumn as shown below.
Checkout the GridTemplateColumn section of following link for more details.
I am new to ASP.Net as well as RAD controls. I have some problem while updating a record using automatic operations.
The scenario is as follows -
I have a grid which displays some information about the employees. I am using automatic operations to edit and delete a particular record. I have a column called as country which stores country_id from another table called "Country" which has 2 columns country_id and country_name. I want to display the country of an employee in the RAD grid column and when clicked on edit link button i want to display a combo box which shows a list of countries (This will be from table "Country" ). When user selects some another country it should get updated into the Employees table. (It should take country_id of selected item of combo and update into the Employees table.)
I am able to show the controls but I am getting the error on ItemUpdated. It says thats "Can not insert Null for column "country" Update Fails. " This means that the control is getting NULL value all the time. I have tried with different column types as well. I have also tried to attach a datasource on ItemDataBound event instead of giveing DataSourceID directly.
Please can anybody suggest a solution to this problem?