Click here to Skip to main content
15,891,744 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a radioButtonList within a GridView and need to populate the radiobuttons by binding through a dataset.
here is the design part.
XML
<asp:GridView runat="server"  ID = "gvIssues1" AutoGenerateColumns="false"  datakeynames="question,question_id" ShowHeader="true" AlternatingRowStyle-BackColor="#FAFAFA" HeaderStyle-BackColor="#F2F2F9">
   <Columns>
   <asp:TemplateField HeaderText="Response Scale" ShowHeader="true">
   <ItemTemplate>
   <asp:RadioButtonList runat="server" ID="rblResponseScale" RepeatDirection="Horizontal" >
   <asp:ListItem  Enabled="true" Text="1" Value ="1"></asp:ListItem>
   <asp:ListItem Enabled="true" Text="2"  Value ="2"></asp:ListItem>
   <asp:ListItem  Enabled="true" Text="3" Value ="3"></asp:ListItem>
   <asp:ListItem  Enabled="true" Text="4" Value ="4"></asp:ListItem>
   <asp:ListItem  Enabled="true" Text="5" Value ="5"></asp:ListItem></asp:RadioButtonList>
   </ItemTemplate>
   </asp:TemplateField>
   </Columns>
   </asp:GridView>


here is the coding part...
string con = System.Configuration.ConfigurationManager.ConnectionStrings["con"].ConnectionString;
            MySqlConnection conn = new MySqlConnection(con);
            MySqlCommand cmd = new MySqlCommand();
            cmd.Connection = conn;
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "Select question_id, response_scale,(Select question from feedbackissues B where B.question_id = A.question_id ) as question from feedback_of_issues A where feedback_sl_no  = @feedback_sl_no order by question_id";

            cmd.Parameters.AddWithValue("@feedback_sl_no", feedback_sl_no);//status is Active status of Question, one(0) is active and if updated to zero(1) it is inactive.
            MySqlDataAdapter adp = new MySqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            adp.Fill(ds);

            if (ds != null)
            {
                gvIssues1.DataSource = ds.Tables[0].DefaultView;
                gvIssues1.DataBind();

                gvIssues1.Visible = true;
                dvIssues1.Visible = true;
            }


how to bind it with dataset. Need ur help, Please help me out.
Thanks in Advance to all of you.
Posted

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900