Best Design to Use RadioButtonList
I have a problem and I would like to know the correct way to solve this problem.
I have Data Objeckt
class LinkHolder {
public string Text;
public string Link;
}
I would like to present the user with a RadioButton list that uses the LinkHolder.Text value as descriptive text. Then in the postback I would like to do
Server.Transfer( LinkHolder.Link )
on the corresponding link.
I'm not sure if this is the best / most correct way to do it. Any hints would be appreciated.
source to share
Your method should work. I think you should be using accessors in your class though
class LinkHolder {
public string Text { get; set;}
public string Link { get; set;}
}
Bind your RadioButtonList to f.ex. List<LinkHolder>
Why would you use a radio riot list instead of just listing your links as hyperlinks instead of using Server.Transfer?
source to share
The LinkHolder class was just an example of a short form. I have accessors in a real class. The radio drums were a design choice, so I went with them.
In my tests, it will print the class name and not the text property when I used List<LinkHolder>
as data source. I don't know how / if you can specify the property that the RadioButtonList should print.
Also I understand that if I use List<LinkHolder>
as a data source, I will not get the LinkHolder object when I ask for the SelectedItem. I will get a ListItem instead.
Any good workaround?
source to share