我有一个14个单选按钮列表,每个表示大学设施,即教室,实验室和运动设施等,我需要一个代码,帮助我为每个单选按钮列表插入一个单独的数据。一个数据库首先有2列列包含设施,第二列包含每个设施的优秀,非常好,良好和平均等级。
<div class="panel-body">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label style="font-size: large">1.Classrooms</label>
<asp:RadioButtonList ID="rbclassrooms" runat="server" RepeatDirection="Horizontal" CellSpacing="10">
<asp:ListItem style="margin-right:50px">Excellent
<asp:ListItem style="margin-right:50px">Very Good
<asp:ListItem style="margin-right:50px">Good
<asp:ListItem style="margin-right:50px">Average
</div>
<div class="form-group">
<label style="font-size: large">2.Laboratories </label>
<asp:RadioButtonList ID="dblab" runat="server" RepeatDirection="Horizontal" CellSpacing="10">
<asp:ListItem style="margin-right:50px">Excellent
<asp:ListItem style="margin-right:50px">Very Good
<asp:ListItem style="margin-right:50px">Good
<asp:ListItem style="margin-right:50px">Average
</div>
<div class="form-group">
<label style="font-size: large">3.Central Library </label>
<asp:RadioButtonList ID="rbcentrallib" runat="server" RepeatDirection="Horizontal" CellSpacing="10">
<asp:ListItem style="margin-right:50px">Excellent
<asp:ListItem style="margin-right:50px">Very Good
<asp:ListItem style="margin-right:50px">Good
<asp:ListItem style="margin-right:50px">Average
</div>
<div class="form-group">
<label style="font-size: large">4. Cleanliness </label>
<asp:RadioButtonList ID="rbclean" runat="server" RepeatDirection="Horizontal" CellSpacing="10">
<asp:ListItem style="margin-right:50px">Excellent
<asp:ListItem style="margin-right:50px">Very Good
<asp:ListItem style="margin-right:50px">Good
<asp:ListItem style="margin-right:50px">Average
</div>
<div class="form-group">
<label style="font-size: large">5. Central Computing Center </label>
<asp:RadioButtonList ID="rbccc" runat="server" RepeatDirection="Horizontal" CellSpacing="10">
<asp:ListItem style="margin-right:50px">Excellent
<asp:ListItem style="margin-right:50px">Very Good
<asp:ListItem style="margin-right:50px">Good
<asp:ListItem style="margin-right:50px">Average
</div>
<div class="form-group">
<label style="font-size: large">6. Wi-Fi Facility </label>
<asp:RadioButtonList ID="rbwifi" runat="server" RepeatDirection="Horizontal" CellSpacing="10">
<asp:ListItem style="margin-right:50px">Excellent
<asp:ListItem style="margin-right:50px">Very Good
<asp:ListItem style="margin-right:50px">Good
<asp:ListItem style="margin-right:50px">Average
</div>
<div class="form-group">
<label style="font-size: large">7. Hostel Facilities </label>
<asp:RadioButtonList ID="rbhostel" runat="server" RepeatDirection="Horizontal" CellSpacing="10">
<asp:ListItem style="margin-right:50px">Excellent
<asp:ListItem style="margin-right:50px">Very Good
<asp:ListItem style="margin-right:50px">Good
<asp:ListItem style="margin-right:50px">Average
</div>
<div class="form-group">
<label style="font-size: large">8. Sport Facility </label>
<asp:RadioButtonList ID="rbsport" runat="server" RepeatDirection="Horizontal" CellSpacing="10">
<asp:ListItem style="margin-right:50px">Excellent
<asp:ListItem style="margin-right:50px">Very Good
<asp:ListItem style="margin-right:50px">Good
<asp:ListItem style="margin-right:50px">Average
</div>
<div class="form-group">
<label style="font-size: large">9. College Bus Transport </label>
<asp:RadioButtonList ID="rbcolgbus" runat="server" RepeatDirection="Horizontal" CellSpacing="10">
<asp:ListItem style="margin-right:50px">Excellent
<asp:ListItem style="margin-right:50px">Very Good
<asp:ListItem style="margin-right:50px">Good
<asp:ListItem style="margin-right:50px">Average
</div>
<div class="form-group">
<label style="font-size: large">10. Canteen Facility</label>
<asp:RadioButtonList ID="rbcanteen" runat="server" RepeatDirection="Horizontal" CellSpacing="10">
<asp:ListItem style="margin-right:50px">Excellent
<asp:ListItem style="margin-right:50px">Very Good
<asp:ListItem style="margin-right:50px">Good
<asp:ListItem style="margin-right:50px">Average
</div>
<div class="form-group">
<label style="font-size: large">11. ATM Facility </label>
<asp:RadioButtonList ID="rbatm" runat="server" RepeatDirection="Horizontal" CellSpacing="10">
<asp:ListItem style="margin-right:50px">Excellent
<asp:ListItem style="margin-right:50px">Very Good
<asp:ListItem style="margin-right:50px">Good
<asp:ListItem style="margin-right:50px">Average
</div>
<div class="form-group">
<label style="font-size: large">12. Counseling and Health Care </label>
<asp:RadioButtonList ID="rbcounselingandhealth" runat="server" RepeatDirection="Horizontal" CellSpacing="10">
<asp:ListItem style="margin-right:50px">Excellent
<asp:ListItem style="margin-right:50px">Very Good
<asp:ListItem style="margin-right:50px">Good
<asp:ListItem style="margin-right:50px">Average
</div>
<div class="form-group">
<label style="font-size: large">13. Washroom and drinking water </label>
<asp:RadioButtonList ID="rbwashroom" runat="server" RepeatDirection="Horizontal" CellSpacing="10">
<asp:ListItem style="margin-right:50px">Excellent
<asp:ListItem style="margin-right:50px">Very Good
<asp:ListItem style="margin-right:50px">Good
<asp:ListItem style="margin-right:50px">Average
</div>
<div class="form-group">
<label style="font-size: large">14. Overall Facilities </label>
<asp:RadioButtonList ID="rboverall" runat="server" RepeatDirection="Horizontal" CellSpacing="10">
<asp:ListItem style="margin-right:50px">Excellent
<asp:ListItem style="margin-right:50px">Very Good
<asp:ListItem style="margin-right:50px">Good
<asp:ListItem style="margin-right:50px">Average
</div>
</div>
答案 0 :(得分:0)
一些选项
1)保持连接打开并执行多个插入语句,如
url = 'getpeopledata.php';
$('.btn-data').click(function(){
var id = $(this).data('people-id');
url += '?id=' + id;
$(some-element)load(url);
});
2)在每个查询上加分号
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
using (SqlCommand cmdClassroom= new SqlCommand("insert into YourTable(Facility,Rank)Values(@facility,@rank)", connection))
{
cmdClassroom.Parameters.AddWithValue(@facility,"Classroom");
cmdClassroom.Parameters.AddWithValue(@rank,rbclassrooms.SelectedValue);
}
//Similarly for next facilities
using (SqlCommand command2 = new SqlCommand(commandText2, connection))
{
}
// etc
}
希望这有帮助!