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

Replace textbox in grid 'Add new record' form with a combobox

5 Answers 158 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 05 Oct 2012, 09:13 AM
Hi

Id like to replace a textbox in the insert form with a combo box that has values poulated from database. Any suggestions?

Thanks in advance

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 05 Oct 2012, 09:39 AM
Hi,

One suggestion is that you can set ReadOnly property as true for the column that is not needed to show in insert mode and show the combobox using InsertItemTemplate.
aspx:
<telerik:GridTemplateColumn>
      <InsertItemTemplate>
          <telerik:RadComboBox ID="RadComboBox1" DataSourceID="SqlDataSource2" DataTextField="Id" DataValueField="Id" runat="server"></telerik:RadComboBox>
      </InsertItemTemplate>
</telerik:GridTemplateColumn>

Thanks,
Princy.
0
Robert
Top achievements
Rank 1
answered on 05 Oct 2012, 09:51 AM
Ok, i dont think i understand what event im gonna set the property in. Does any event fire when i press Add new record button, where i can manipulate the form before its rendered?
0
Princy
Top achievements
Rank 2
answered on 06 Oct 2012, 05:10 AM
Hi,

You can check for the event in ItemCommand event as shown below.
C#:
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
 if (e.CommandName == RadGrid.InitInsertCommandName)
 {
 }
}

Thanks,
Princy.
0
Robert
Top achievements
Rank 1
answered on 06 Oct 2012, 12:56 PM
Ok, ive managed to accomplish to get a combobox to show and hide the textbox, but i want the combo box in the same place the textbox was, cant i just replace it insetead of adding a new control and hiding the old one?

Seems very complicated to do such a simple thing, cant i manipulate the collection of input controls somewhere directly?
0
Princy
Top achievements
Rank 2
answered on 08 Oct 2012, 05:05 AM
Hi,

One suggestion is that you can set the Visibility of the controls in Edititemtemplate as shown below.
aspx:
<telerik:GridTemplateColumn>
     <EditItemTemplate>
     <asp:TextBox ID="TextBox1" runat="server" Visible='<%#(Container is GridEditFormInsertItem)? false : true %>'></asp:TextBox>
      <telerik:RadComboBox ID="RadComboBox1" DataSourceID="SqlDataSource2" DataTextField="EmployeeID" DataValueField="EmployeeID" runat="server" Visible='<%#(Container is GridEditFormInsertItem)? true : false %>' ></telerik:RadComboBox>
      </EditItemTemplate>
</telerik:GridTemplateColumn>

Thanks,
Princy.
Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Robert
Top achievements
Rank 1
Share this question
or