如何将GridView中的RadioButtonList与数据集列绑定。 [英] How to bind RadioButtonList in GridView with dataset column.
本文介绍了如何将GridView中的RadioButtonList与数据集列绑定。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在GridView中有一个radioButtonList,需要通过数据集绑定来填充radiobuttons。
这里是设计部分。
i have a radioButtonList within a GridView and need to populate the radiobuttons by binding through a dataset.
here is the design part.
<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.
推荐答案
http://www.c-sharpcorner.com/UploadFile/54db21/gridview-with-radiobutton-binding/ [ ^ ]
参考本网站
http://www.c-sharpcorner.com/UploadFile/54db21/gridview-with-radiobutton-binding/[^]
Refer this site
这篇关于如何将GridView中的RadioButtonList与数据集列绑定。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文