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

Ajax and combo

5 Answers 50 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
John Giblin
Top achievements
Rank 1
John Giblin asked on 21 Dec 2012, 01:25 PM
I am having strange results with the combo box.  For some reason it is rebindig after I bind it.  
My first issue was u was trying to remove an item from the list if it was not selected.  Since it was doing this word reminding,  I had to remove it on the ondataload method. The next problem was that the selected value was not remaining. I set the value.  I step through the code and I see it being set.  Then when the page is displayed the value is no longer set.  How can I track these behind the scenes processes. 

5 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 2
answered on 21 Dec 2012, 06:31 PM
Hello John,

From your description I don't quite understand what is going on. Would be able to post what your page markup and code looks like, so we can see where the problem is?
0
John Giblin
Top achievements
Rank 1
answered on 21 Dec 2012, 07:12 PM
I wish I could. Besides being long, I cant post it. 


But there is a editpage opens a window that is triggered inside a radgrid (RadGrid1_ItemCommand)

 

 

 

 

 

var currentRow = otv.Items[e.Item.ItemIndex];

 

//set some page values

 

otv.IsItemInserted = false;

 

otv.EditFormSettings.UserControlName =

 

"UserControls/frmXXX.ascx";


The mysterious thing is I put break points in  "UserControls/frmXXX.ascx"  where I see that combo box.  I step through the code. It sets it, but at the end I see the OnDataBound hits 2x.  But I dont see howor where that is being triggered from.

any help would be appreciated.  Sorrry for the lack of code

John

 

0
Kevin
Top achievements
Rank 2
answered on 22 Dec 2012, 04:20 PM
Hello John,

The double rebind makes sense now. The reason it binds twice is once from you explicitly calling it and then again by the RadGrid which tells it child controls to bind themselves. If this UserControl is only going to be used as the EditForm for the RadGrid, I would suggest not explicitly calling the DataBind method on the RadComboBox and just leave it up to the RadGrid to call databind.

I hope that helps.
0
John Giblin
Top achievements
Rank 1
answered on 27 Dec 2012, 02:58 PM
thanks kevin. I will try that.  The one thing I also found weird is that I looked everywhere in "UserControls/frmXXX.ascx"; for the combo box and put breakpoints where it sets it. I see the ondatabound being hit 2x.  but I can only see it hit the area one time where it gets the data and sets the value.  When I run the debugger, it steps through and the value is set correctly and then it is step through the ascx page and then it unsets it.

The 2 things I was trying to accomplish is not to get double values in the drop-down, remove a value and have the value set correctly.
 So I:
  1. removed the attribute: AppendDataBoundItems which affected the value from being set behind code, 
  2. Set the value in the ascx page to solve the above issue
  3. use the onDatabound to remove an item


Btw I tried to post the code but I can only attach images

0
John Giblin
Top achievements
Rank 1
answered on 11 Jan 2013, 05:11 PM
Is there any way of know when you use an item template within the grid.  

I usually us Page.IsPostBack to tell whether to set up the form fields.  but in this case it comes up true 

thanks in advance
Tags
ComboBox
Asked by
John Giblin
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 2
John Giblin
Top achievements
Rank 1
Share this question
or