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

Not able to Find a control in the itemtemplate of the listbox

3 Answers 59 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Civbaron
Top achievements
Rank 1
Civbaron asked on 19 Jun 2010, 03:47 AM
Hi,

I am trying to set a controls value, based on values sent from one listbox to the other. I have set up code to find the control in the ontransferred event of the listboxes. Currently I am using the findcontrol method of listbox that the item is being sent to, then I try to find the control by the ID. When the code runs though the control is being set to a null value instead of the control in the listbox.

Thanks,
jonathan

3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 21 Jun 2010, 07:54 AM
Hello Jonathan,

The provided information is not enough for us to reproduce this issue, please send us some simple code. Thanks

Kind regards,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Civbaron
Top achievements
Rank 1
answered on 21 Jun 2010, 03:01 PM
Hi Yana,

I have pasted some of the code behind that I am currently using to try to find the control so that I can set the value of the control in the list box once it is transferred.

 

protected void lbUserNotAssigned_OnTransferred(object sender, RadListBoxTransferredEventArgs e)

 

{

 

if (e.DestinationListBox == lbUserAssigned)

 

{

 

Transform sut = new Transform(AppSettingManager.SBFDatabase);

 

 

for (int i = 0; i < e.Items.Count; i++)

 

{

 

List<User> users = sut.Get(int.Parse(e.Items[i].Value));

 

 

if (users.Count>0)

 

{

 

Label lblusername = (Label)lbUserAssigned.FindControl("lblUserName");

 

lblusername.Text = siteusers[i].Name;

 

RadComboBox rb1= (RadComboBox)lbUserAssigned.FindControl("rcbStyle");

 

rb1.SelectedValue = siteusers[i].DefaultStyleGroupId.ToString();

 

RadComboBox rb2= (RadComboBox)lbUserAssigned.FindControl("GroupId");

 

rb2.SelectedValue = siteusers[i].PrimarySecurityGroupId.ToString();

 

RadComboBox rb3= (RadComboBox)lbUserAssigned.FindControl("PrimaryGroupId");

 

rb3.SelectedValue = siteusers[i].PrimaryNarrGroupId.ToString();

 

RadComboBox rb4= (RadComboBox)lbUserAssigned.FindControl("PrimaryId");

 

rb4.SelectedValue = siteusers[i].PrimaryBusinessGroupId.ToString();

}

 

else

 

{

 

Transform ut = new Transform(AppSettingManager.SBFDatabase);

 

 

IUser user = ut.GetByUserSeq(int.Parse(e.Items[i].Value));

 

 

Label lblusername = (Label)lbUserAssigned.FindControl("lblUserName");

 

lblusername.Text = user.Name;

}

}

}

0
Yana
Telerik team
answered on 24 Jun 2010, 01:21 PM
Hi Jonathan,

Please send us also the markup. Thanks in advance

Best wishes,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ListBox
Asked by
Civbaron
Top achievements
Rank 1
Answers by
Yana
Telerik team
Civbaron
Top achievements
Rank 1
Share this question
or