Search code examples
c#asp.netradiobuttonlistcorrectness

Best design for RadioButtonList usage


I have a problem and i would like to learn the correct way to solve this.

I have a Data Objeckt

class LinkHolder {
    public string Text;
    public string Link;
}

I would like to present to the user a RadioButton list that uses the LinkHolder.Text value as descriptive text. Then on the postback, i would like to do a

Server.Transfer( LinkHolder.Link ) 

on the corresponding Link.

I am unsure what is the best/most correct way to do this. Any hints would be appreciated.


Solution

  • You need to set DataTextField and DataValueField on your RadioButtonList. Then the correct values should show up.

    You can try to cast the selectedItem into a LinkHolder.