0 Replies - 1732 Views - Last Post: 05 August 2013 - 01:14 PM Rate Topic: -----

#1 NitroFrost   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 25-October 09

Fill in radiobuttonlist from database

Posted 05 August 2013 - 01:14 PM

I have a radio button list with two buttons. Pretty much a yes and a no. The user would select one and hit the save button. The yes or the no is set to a 0 or 1 value. 0 for no 1 for yes or true false. This gets stored in my database(bit column). I am trying to retrieve that information from the database and fill in the result when the user wants to edit their selection. Here is the relevant code.

    <fieldset id="Fieldset1" style="display: inline-block; width: 138px;">
    <label style="top: 0"><span class="star">∗</span><b><u>AMI Event Options</u></b></label>
    <asp:RadioButtonList ID="EventBoolAMI" runat="server">
        <asp:ListItem Text="AMI Event" Value="0"/> 
        <asp:ListItem Text="Non-AMI Event" Value="1" />

foreach (RadioButtonList nonAMIevent in EventBoolAMI.Items)
      switch (nonAMIevent.SelectedItem.Value)
        case "AMI Event":
            nonAMIevent.SelectedItem.Value = Convert.ToBoolean(theEvent.Rows[0][5]);
        case "Non-AMI Event":
            nonAMIevent.SelectedItem.Value = Convert.ToBoolean(theEvent.Rows[0][5]);

Now I figure I don't need a for loop here but I am trying to understand how I am going to get the value from the database and how I am going to set that value. The value from the database is a bit(0 or 1). So I need to set which is is. The way the list is it would evaluate weather the AMI EVENT is selected or the NON is selected because the list items have the values 0 or 1.

I did something similar that works perfect for a combobox but this is a different control so I understand it needs different logic. Any help would once again be greatly appreciated. Here is the code from what I did.

    <telerik:RadComboBox ID="NotifyOptions" CheckBoxes="true" OnClientSelectedIndexChanged="NotifyOptions_SelectedIndexChanged"
        runat="server" EmptyMessage="Notification Options"
        onselectedindexchanged="NotifyOptions_SelectedIndexChanged" Width="150px" 
        CollapseAnimation-Duration="0" ExpandAnimation-Duration="0" >
            <telerik:RadComboBoxItem Value="phone" Text="Phone" />
            <telerik:RadComboBoxItem Value="text" Text="Text Message" />
            <telerik:RadComboBoxItem Value="email" Text="Email" />
            <telerik:RadComboBoxItem Value="all" Text="All" />

    foreach (RadComboBoxItem notifyItem in NotifyOptions.Items)
        switch (notifyItem.Value)
            case "all":
              notifyItem.Checked = Convert.ToBoolean(theEvent.Rows[0][9]);
            case "email":
              notifyItem.Checked = Convert.ToBoolean(theEvent.Rows[0][6]);
            case "text":
              notifyItem.Checked = Convert.ToBoolean(theEvent.Rows[0][7]);
            case "phone":
              notifyItem.Checked = Convert.ToBoolean(theEvent.Rows[0][8]);

Is This A Good Question/Topic? 0
  • +

Page 1 of 1