Pregunta

I need to write a code to retrieve data from Sqlserver DATABASE

That data is value from the field called: NewProducer. It contains 0 - 1.

I need to retrieve and show them in Radiobuttonlist.

The value is:

0 = "Ex Producer"
1 = "New Producer"

I write a code like this

     RadioButtonList1.Items.FindByValue(convertInteger(dt.Rows(0)("NewProducer"))).Selected = True

from Producer Table

when I compiled it show just a 0 and 1 in the radio button list

I got stuck that I can't change the radio button list to show "Ex Producer" and "New Producer" Replace the 0 and 1

¿Fue útil?

Solución

May be this link can help you.

Databinding of RadioButtonList using SelectedValue...possible?

I think if you have only those two values, you can declare them in the aspx page itself like below:

<asp:RadioButtonList runat="server" ID="RadioButtonList1">
    <asp:ListItem Value="0" Text="Ex Producer" />
    <asp:ListItem Value="1" Text="New Producer" />
</asp:RadioButtonList>

After that in code behind you can use your code:

ListItem item = RadioButtonList1.Items.FindByValue(ConvertToInteger(dt.Rows[0]["NewProducer"].ToString();
if(item != null)
item.Selected = true;
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top