Hi,
This one has been hard to find an answer for despite checking many posts. I have a radgrid with an embedded radcombobox. The fields in the grid look like this with a GridTemplateColumn that contains the radcombobox called cboGuageName:
I am able to set the radcombobox in the grid with the correct value and display the grid when not in edit mode using the following code in needdata source code event as follow:
When click the edit link the code below executes which is in the itemdata event for the radgrid; it finds the right key, retrieves the correct grid data for the row, and sets the radcombobox selected with the value for that field. .However the code that grabs the combobox returns null so there is nothing to assign the gridrow's value to. Worst of all the program will not go up into editable mode after clicking the edit link; it either does nothing or the cursor spins endlessly.
Here is the code in itemdata event for the grid:
described above:
I've tried many things but nothing seems to work. Any advice would be appreciated.
Neil
This one has been hard to find an answer for despite checking many posts. I have a radgrid with an embedded radcombobox. The fields in the grid look like this with a GridTemplateColumn that contains the radcombobox called cboGuageName:
<telerik:GridBoundColumn UniqueName="MeasureName" DataField="MeasureName" HeaderText="MeasureName" ReadOnly="true"></telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Min" DataField="Min" HeaderText="Min"></telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Max" DataField="Max" HeaderText="Max"></telerik:GridBoundColumn>
<%--<telerik:GridBoundColumn UniqueName="GuageName" DataField="GuageName" HeaderText="GuageName"></telerik:GridBoundColumn>--%>
<telerik:GridTemplateColumn UniqueName="GuageName" HeaderText="Guage Name" DataField="GuageName" HeaderStyle-Width="200px">
<itemtemplate>
<%# Eval("GuageName")%>
</itemtemplate>
<edititemtemplate>
<telerik:RadComboBox ID="cboGuageName" OnLoad="cboGuageName_Load" AutoPostBack="true" DataTextField="GuageName" DataValueField="GuageName" SelectedValue='<%# Bind("GuageName") %>' runat="server" Width="140px"></telerik:RadComboBox>
</edititemtemplate>
</telerik:GridTemplateColumn>
I am able to set the radcombobox in the grid with the correct value and display the grid when not in edit mode using the following code in needdata source code event as follow:
if (lstDocType.SelectedIndex >= 0)
{
using (var db = new SpecCheck.Models.TorqDevEntitiesNewTest())
{
string dbase = db.Database.Connection.ConnectionString;
RadWindowManager1.RadAlert("Database is " + dbase + "-Need", 400, 180, "ALERT", null, null);
Guid docId = new Guid(lstDocType.SelectedItem.Value.ToString());
var measure = db.DocumentMeasureTypes.Where(d => d.DocumentTypeId == docId).Select(d => new { d.DocumentMeasureTypeId, d.MeasureName, d.Min, d.Max, d.GuageName, d.Sort }).OrderBy(d => d.Sort).ToList();
RadGridMeasureType.DataSource = measure;
//RadDropDownList ddl1 = edit1["Description"].FindControl("cboDocType") as RadDropDownList;
}
}
When click the edit link the code below executes which is in the itemdata event for the radgrid; it finds the right key, retrieves the correct grid data for the row, and sets the radcombobox selected with the value for that field. .However the code that grabs the combobox returns null so there is nothing to assign the gridrow's value to. Worst of all the program will not go up into editable mode after clicking the edit link; it either does nothing or the cursor spins endlessly.
Here is the code in itemdata event for the grid:
described above:
using (var dbMeasureType = new SpecCheck.Models.TorqDevEntitiesNewTest())
//if (e.Item is GridDataItem)
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem editItem = (GridEditableItem)e.Item;
//Access the RadDropDownList
RadComboBox guageType = (RadComboBox)editItem.FindControl("GuageName");
var key = (Guid)editItem.GetDataKeyValue("DocumentMeasureTypeId");
//using (var db = new TorqDevEntitiesNewTest())
//{
var measures = dbMeasureType.DocumentMeasureTypes.Find(key);
guageType.SelectedValue = (String)(measures.GuageName);
}
I've tried many things but nothing seems to work. Any advice would be appreciated.
Neil