Hi,
Very new to telerik. I have a radgrid that has a radcombobox in each row using an edititemtemplate. For each row I'm trying to get the value in the data source for the radgrid and then set the radcombobox to that same value. Eventually I want to choose a value from the radcombox and save the grid using that value for that same field in the radgrid. So there is one field in the radgrid that is always tied to the radcombobox for any row
After some digging I figured out how to get the value in the radgrid for the field I want in the ItemDatabound event:
if (e.Item is GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
string Line = item.GetDataKeyValue("WO_ID").ToString();
//string MachineID = (item["Machine"].Controls[0]).ToString();
string s = ((DataRowView)e.Item.DataItem)["MachineID"].ToString();
RadComboBox cboMachine = item.FindControl("cboMachine") as RadComboBox;
cboMachine.SelectedValue = s;
}
What I would like to do now is take the the "s" variable and set the combobox to that value (this would be on the first display of the screen). As you can see in the line:
cboMachine.SelectedValue = s;
I was attempting to set the combobox to the value that is read into the radgrid;unfortunately the findcontrol I used did not find the combobox control. What I think I found in my naive understanding of this is that I couldn't get to combo box as a control and set it as long as I was using this if statement
"if (e.Item is GridDataItem)"
It seemed I need to use GridEditFormItem.The problem is that would involve require another call to ItemDataBound and I'd lose the value I got from the grid is the variable "s". I suppose I could make "s" a session variable but that seems clumsy and not decent design. I'm sure I'm missing something.
Any help would be appreciated.
Thanks,
Neil