测验演示编码 [英] quiz demo coding
问题描述
我目前正在从事在线考试网络项目..我有一个这样的表格..
sno问题answer1 answer2 answer3 answer4
正确答案
1 sql结构化简单简短没有结构化
我只想将这4个答案绑定到存在于gridview中的单选按钮列表中.无法执行此操作,所以请帮助我
这是我尝试过的,
aspx代码:
< asp:TemplateField ItemStyle-HorizontalAlign =" HeaderText =" 在线测试!" < ItemTemplate >
< asp:Label ID =" runat 服务器" 文本 <%#Eval(" )
高度 =" 16像素" 宽度 800px"
字体大小 =" X-Small" < /asp:标签 >
< br >
< asp:RadioButtonList ID =" =" 服务器" 字体大小 ="
RepeatDirection =" 水平" >
< /asp:RadioButtonList >
< /ItemTemplate >
< EditItemTemplate >
< asp:TextBox ID =" runat 服务器" 文本 <%#Bind(" )
宽度 =" 187像素" < /asp:TextBox >
< /EditItemTemplate >
< ItemStyle =" 左侧" < >
< /asp:TemplateField >
C#代码:
受保护的 无效 GridView1_RowDataBound(对象发件人,GridViewRowEventArgs e)
{
myConnection.Open();
cmd = 新 SqlCommand(" + employee.BranchId + '和pn_questID ='" + txt_qsetno.Text + " ,myConnection);
rea1 = cmd.ExecuteReader();
如果(rea1.Read())
{
RadioButtonList rbl_responses =(RadioButtonList)e.Row.Cells [ 1 ].FindControl(" RadioButtonList6");
如果(例如,Row.RowType == DataControlRowType.DataRow)
{
rbl_responses.Items.Add(新 ListItem(Convert.ToString(rea1 [" ]))));
rbl_responses.Items.Add(新 ListItem(Convert.ToString(rea1 [" ]))));
rbl_responses.Items.Add(新 ListItem(Convert.ToString(rea1 [" ]))));
rbl_responses.Items.Add(新 ListItem(Convert.ToString(rea1 [" ]))));
}
rea1.Close();
myConnection.Close();
}
这不起作用,我不知道如何将4个答案字段绑定到单选按钮列表..
希望 ^ ]会给您一个想法. /blockquote>
Hi ,
I''m currently working on an online examination web project.. i have a table like this..
sno question answer1 answer2 answer3 answer4
correctanswer
1 sql structured simple short none structured
I just want to bind these 4 answers to my radiobuttonlist which is present inside the gridview.. am not able to do that so please help me
here is what i''ve tried ,
Aspx code : <asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText=" Online Test !"> <ItemTemplate> <asp:Label ID="lbl_que" runat="server" Text='<%# Eval("questions") %>' Height="16px" Width="800px" Font-Size="X-Small"></asp:Label> <br /> <asp:RadioButtonList ID="RadioButtonList6" runat="server" Font-Size="X-Small" RepeatDirection="Horizontal" > </asp:RadioButtonList> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="txt_que_edit" runat="server" Text='<%# Bind("questions") %>' Width="187px"></asp:TextBox> </EditItemTemplate> <ItemStyle HorizontalAlign="Left"></ItemStyle> </asp:TemplateField>
C# code : protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { myConnection.Open(); cmd = new SqlCommand("select option1 , option2 , option3 , option4 from online where pn_BranchID = '" + employee.BranchId + "' and pn_questID='" + txt_qsetno.Text + "' ", myConnection); rea1 = cmd.ExecuteReader(); if (rea1.Read()) { RadioButtonList rbl_responses = (RadioButtonList)e.Row.Cells[1].FindControl("RadioButtonList6"); if (e.Row.RowType == DataControlRowType.DataRow) { rbl_responses.Items.Add(new ListItem(Convert.ToString(rea1["option1"]))); rbl_responses.Items.Add(new ListItem(Convert.ToString(rea1["option2"]))); rbl_responses.Items.Add(new ListItem(Convert.ToString(rea1["option3"]))); rbl_responses.Items.Add(new ListItem(Convert.ToString(rea1["option4"]))); } rea1.Close(); myConnection.Close(); }
This isn''t working, i dont know how to bind the 4 answers fields to the radiobuttonlist..解决方案Hope this[^]will give you an idea.
这篇关于测验演示编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!