can't find control inside ListView

5 posts, 1 answers
  1. jaws1021
    jaws1021 avatar
    41 posts
    Member since:
    Jun 2012

    Posted 15 Jun 2012 Link to this post

    I have a RadCombobox inside the RadListView ItemTemplate. From RadComboBox SelectedIndexChanged I am trying to update database, but RadCOmbobox value comes back null. 

     protected void ddCustomer_SelectedIndexChanged(object sender, System.EventArgs e)
            {
                RadComboBox ddCustomer = (RadComboBox)RadListView1.FindControl("ddCustomer");
                ---- it shows ddCustomer null. How can I find the control?
               ----- is there anyway, I can reach datakeys from here also?          
            }
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 15 Jun 2012 Link to this post

    Hello,

    Try the following code snippet to achieve your scenario.

    C#:
    protected void ddCustomer_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
      {
         RadComboBox ddCustomer = (RadComboBox)sender;
         RadListViewDataItem ditem = (RadListViewDataItem)ddCustomer.NamingContainer;
         string DataKey = ditem.GetDataKeyValue("DataKeyName").ToString();
      }

    Hope this helps.

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. jaws1021
    jaws1021 avatar
    41 posts
    Member since:
    Jun 2012

    Posted 15 Jun 2012 Link to this post

    Thank you Shinu!
  5. Nate
    Nate avatar
    1 posts
    Member since:
    Feb 2013

    Posted 26 Feb 2013 Link to this post

    Can you post the solution for VB.net?
  6. Eyup
    Admin
    Eyup avatar
    3014 posts

    Posted 01 Mar 2013 Link to this post

    Hi Nate,

    Please note that you can use Code Converter:
    http://converter.telerik.com/

    Hope this helps. Please give it a try and let me know about the result.

    Regards,
    Eyup
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017