Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
One last DataBindings question
Message
 
To
23/01/2006 12:50:04
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01089266
Message ID:
01089985
Views:
18
I haven't had to do that yet. I am sure I will want to do that in the future and then I will come back here to ask you :)
Einar

>That doesn't look too bad, Einar. My problem was trying to figure out how to bind to a DataTable instead of a property.
>
>~~Bonnie
>
>
>
>>Thanks for the reply. I guess I was expecting that reply from what I have been reading around the internet.
>>After posting the original message I discovered that the problem I had was not related to the way I databind a radiobutton group.
>>Here is the code I use to databind a usercontrol with 7 radiobuttons (I would normaly use an enum instead of the int but I didn't feel like creating en enum for this example):
>>
>>public int UserControlValue
>>{
>>	get
>>	{
>>		int i = 1;
>>		if (this.radioButton1.Checked)
>>			i = 1;
>>		if (this.radioButton2.Checked)
>>			i = 2;
>>	         if (this.radioButton3.Checked)
>>			i = 3;
>>		if (this.radioButton4.Checked)
>>			i = 4;
>>		if (this.radioButton5.Checked)
>>			i = 5;
>>		if (this.radioButton6.Checked)
>>			i = 6;
>>		if (this.radioButton7.Checked)
>>			i = 7;
>>		return i;
>>	}
>>	set
>>	{
>>		if (value == 1)
>>			this.radioButton1.Checked = true;
>>		if (value == 2)
>>			this.radioButton2.Checked = true;
>>		if (value == 3)
>>			this.radioButton3.Checked = true;
>>		if (value == 4)
>>			this.radioButton4.Checked = true;
>>		if (value == 5)
>>			this.radioButton5.Checked = true;
>>		if (value == 6)
>>			this.radioButton6.Checked = true;
>>		if (value == 7)
>>			this.radioButton7.Checked = true;
>>	}
>>}
>>
>>public void DataBind(object o)
>>{
>>	this.DataBindings.Clear();
>>	this.DataBindings.Add("UserControlValue", o, "ObjectValue");
>>}
>>
>>
>>Please let me know if you see any problems with this. It is a shame to let a good usercontrol (like the radiobutton) go to waste :)
>>
>>Einar
>>
>>>Here's the secret to radio buttons ... DON'T <g> ... I could never figure out a good way to make them work, they were just too much trouble for me, so I just don't bother to use them.
>>>
>>>Thanks for the confidence in my ability to answer every question you ever ask, but I guess I let you down on this one. <g> Maybe someone else has some tips for getting these puppies to behave properly, but I sure don't.
>>>
>>>I wonder if they've improved at all in 2.0? I haven't tried.
>>>
>>>~~Bonnie
>>>
>>>
>>>
>>>>Bonnie,
>>>>This is the last DataBindings question I promise (I have my fingers crossed just in case <s>, which makes it really difficult to type<s>).
>>>>
>>>>The control of the hour is the radiobutton. I have in the past created a property in my usercontrol (containing a number of radio), the set would check one of the radiobuttons and the get would return a value related to the checked radiobutton. Then I would have a similar (same type) property in my biz object. Then I would do the following to databind the usercontrol:
>>>>
>>>>this.myUserControl.DataBindings.Add("myUserControlProperty", myObject, "myObjectProperty")
>>>>
>>>>
>>>>This worked great until I late last night noticed some odd behaviour.
>>>>
>>>>So after I was 100% sure that the Panthers would loose :) I created a test app: a usercontrol with 7 radiobuttons, a class with 7 bool properties. The usercontrol also has a method called DataBind where I add a databinding between each of the radiobuttons and the appropriate object property. I called the DataBind method from the form's load event. I guess I expected it to work, but I wasn't surprised when it didnt work.
>>>>
>>>>So any hints for my radiobuttin "group" data binding?
>>>>
>>>>Thanks,
>>>>Einar
>>>>
>>>>PS. Anyone can reply I just figured Bonnie would reply first so I might as well create the message to her.
>>>>
>>>>UPDATE: I just discovered that my radio button group binding issue was related to something else. I am not exacly sure what, but I am sure it is something else. Any who I would still like to know how ya'll bind a radiobutton group.
Semper ubi sub ubi.
Previous
Reply
Map
View

Click here to load this message in the networking platform