infolink

Wednesday, December 7, 2011

How to retrive value from Telerik RadComboBox in RadGrid on insert

I was having an issue getting the SelectedValue from the telerik RadComboBox control in a rad grid. Here is how you do it:

The front End code:

       <telerik:GridDropDownColumn DataSourceID="DSCategories" ListTextField="CategoryName" ListValueField="CategoryID"
                    UniqueName="CategoryDD" SortExpression="CategoryName" HeaderText="Category" DataField="CategoryID"
                    DropDownControlType="RadComboBox" FooterText="RadComboBox column footer"
                    AllowAutomaticLoadOnDemand="true" AllowVirtualScrolling="true" ShowMoreResultsBox="true"
                    ItemsPerRequest="10">
    </telerik:GridDropDownColumn>

The Backend Code:

    protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e)

 {
   GridEditFormInsertItem insertItem = e.Item as GridEditFormInsertItem;
   RadComboBox DDCat = (insertItem["CategoryDD"].Controls[0] as RadComboBox);
   int DDcategory = Convert.ToInt16(DDCat.SelectedValue);
  }
Buy Me a Beer

Please Donate To Bitcoin Address: [[address]]

Donation of [[value]] BTC Received. Thank You.
[[error]]

5 comments:

  1. James,
    Thanks a lot for sharing. This post saved me a lot of time. I appreciate your help very much. This really is a wonderful world.

    ReplyDelete
  2. Very glad I could help, the whole reason I post anything on his blog is for exactly that, to help save someone else the time and pass on the knowledge.

    Thank you,
    James Campbell
    MCP,MCSA,MCSE,Security +
    tel - five seven zero - 223 - 8452

    ReplyDelete
  3. hi..how can I apply this if my combobox belongs to EditTemplate?

    ReplyDelete
    Replies
    1. Can you post your code in which you have it in the EditTemplate?

      Thank you,
      Jim

      Delete

Amazon1