Supposed I have the form below with values coming from a database, how do I know which Item was selected selected? Please not value store on db is as text not true or false.
---- aspx page-----
<form runat="server"><asp:RadioButtonList id="radiolist1" runat="server"><asp:ListItem GroupName="Software"AutoPostBack="true">Asp.net</asp:ListItem><asp:ListItem GroupName="Software"AutoPostBack="true">Coldfusion</asp:ListItem><asp:ListItem GroupName="Software"AutoPostBack="true">C</asp:ListItem><asp:ListItem GroupName="Software"AutoPostBack="true">Other</asp:ListItem></asp:RadioButtonList><br><asp:Button text="Update" OnClick="submit" runat="server"/>
---aspx.cs ----
protected void Page_Load(object sender, EventArgs e) { using (OracleConnection con = new OracleConnection(connectionString)) { string sql_select = "SELECT softwareType FROM HABBIESTABLE WHERE USER='" + id.ToString() + "'"; OracleCommand cmnd = new OracleCommand(sql_select, con); con.Open(); OracleDataReader reader = cmnd.ExecuteReader(); while (reader.Read()) { // I don't know what I am doing here below :( ListItem item = new ListItem(); item.Text = reader["softwareType"].ToString(); item.Value = reader["RadioButtonMyItems"].ToString(); item.Selected = Convert.ToBoolean(reader["softwareType"]); RadioButtonCourses.Items.Add(item); } }
I can't get it to work. Can you help?!
Thank you everyone