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

[Solved] How do I set up a dropdown box using the SetupInputManager model?

2 Answers 113 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Boris
Top achievements
Rank 1
Boris asked on 18 Mar 2013, 08:14 PM
I'm looking at your demo http://www.telerik.com/help/aspnet-ajax/grid-linq-to-sql-manual-crud-operations.html.

I've used it successfully in the past but now I need a combo box dropdown and I'm getting nowhere.  It crashes on Object reference not set to an instance of an object.

Where is a decent example?
-----------------------
Here's my code.  I've already verified that the correct data is being returned to the DataSource.

  GridDropDownListColumnEditor rcb = ((GridDropDownListColumnEditor)editableItem.EditManager.GetColumnEditor("Field1"));
  rcb.DataTextField = "text";
 rcb.DataValueField = "value";           
 rcb.DataSource = HSSDDataLayerStatic.getFieldStatus();
 rcb.DataBind();            
 inputSetting.TargetControls.Add(new TargetInput(rcb.UniqueID, true));


2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Mar 2013, 06:39 AM
Hi,

Try the following code to add input settings.
C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
          GridEditableItem item = (GridEditableItem)e.Item;
           RadInputManager mgr = (RadInputManager)item.FindControl("RadInputManager1");
           TextBoxSetting inputSetting = new TextBoxSetting();
           inputSetting.TargetControls.Add(new TargetInput(rcb.UniqueID, true));
           mgr.InputSettings.Add(inputSetting);
        }
}

Thanks,
Shinu
0
Boris
Top achievements
Rank 1
answered on 19 Mar 2013, 01:07 PM
Update.  I still don't understand your answer but I may possibly have found my problem.  There's a DropdownControlType property on the Dropdown column.  Whatever this is, it defaults to RadComboBox.  This does not work.  The alternative, Dropdownlist, does, at least in this style of coding.   To be continued...

I'm sorry.  I am completely lost.  I cannot relate your answer to my problem.  (Why would you be looking for a RadInputManager in the e.item?  That simply does not work.)

Let me repeat the problem.

I first have the ItemCreated code;
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
   if (e.Item is GridEditableItem && (e.Item.IsInEditMode))
   {
        GridEditableItem editableItem = (GridEditableItem)e.Item;
        SetupInputManager(editableItem);
   }
}

In the SetupInputManager method I have the following for an assortment of text fields. With these I have no need to go all out and code a FormTemplatePopup.  These work fine but now I need a combobox, not a textbox.  

var textBox =
   ((GridTextBoxColumnEditor)editableItem.EditManager.GetColumnEditor("AUniqueColumn")).TextBoxControl;
   textBox.MaxLength = 255;
   textBox.Width = new System.Web.UI.WebControls.Unit("500px");
   InputSetting inputSetting = RadInputManager1.GetSettingByBehaviorID("TextBoxSetting1");
   inputSetting.TargetControls.Add(new TargetInput(textBox.UniqueID, true));       
   inputSetting.Validation.IsRequired = true;
Tags
Grid
Asked by
Boris
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Boris
Top achievements
Rank 1
Share this question
or