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

can't find control inside ListView

4 Answers 146 Views
ListView
This is a migrated thread and some comments may be shown as answers.
jaws1021
Top achievements
Rank 1
jaws1021 asked on 15 Jun 2012, 06:27 AM
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?          
        }

4 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 15 Jun 2012, 08:36 AM
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.
0
jaws1021
Top achievements
Rank 1
answered on 15 Jun 2012, 05:47 PM
Thank you Shinu!
0
Nate
Top achievements
Rank 1
answered on 26 Feb 2013, 10:36 PM
Can you post the solution for VB.net?
0
Eyup
Telerik team
answered on 01 Mar 2013, 09:55 AM
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.
Tags
ListView
Asked by
jaws1021
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
jaws1021
Top achievements
Rank 1
Nate
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or