Hi All,
I have added a RadioButtonList inside a repeater as follows:
(.aspx file):
<asp:Button ID="Button1" Text="Add Comment" runat="server" />
<asp:Panel ID="pnlPanelDemo" runat="server" CssClass="modalPopup" ViewStateMode="Disabled">
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</cc1:ToolkitScriptManager>
<asp:Repeater ID="rptComments" runat="server">
<ItemTemplate> <table>
<tr> <td>
<asp:Label ID="lblName" runat="server" Text='<%# Eval("QUESTION_DESC") %>'></asp:Label>
</td>
<td style="padding-left: 20px;">
<asp:RadioButtonList ID="RadioButtonList1" runat="server" Height="48px" RepeatDirection="Horizontal" Width="510px">
<asp:ListItem>Very Poor</asp:ListItem>
<asp:ListItem>Poor</asp:ListItem>
<asp:ListItem>Average</asp:ListItem>
<asp:ListItem>Good</asp:ListItem>
<asp:ListItem>Very Good</asp:ListItem>
</asp:RadioButtonList>
</td> </tr>
</table>
</ItemTemplate> </asp:Repeater>
<table> <tr> <td>
</td>
<td style="padding-left: 20px;">
<asp:Button ID="btnAdd" runat="server" OnClick="AddComment" Text="Add Comment" />
</td> <td>
</td> </tr>
</table>
Now suppose if 3 questions are displayed on the webpage then 3 radiobuttonlists are displayed. I need to send the selected text of radiobuttons separately in my table in SQL Server on a button click event.
Suppose if selected answers are Very Poor, Average and Good then database entry should look like:
1 Very Poor
2 Average
3 Good
(.aspx.cs file)
protected void AddComment(object sender, EventArgs e) {
string constr = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
string sqlStatment = "INSERT INTO FeedbackResponse(QUESTION_ID,RESPONSE) values(@QID,@RESP)";
using (SqlConnection con = new SqlConnection(constr)) {
using (SqlCommand cmd = new SqlCommand(sqlStatment, con))
{ con.Open();
cmd.Parameters.AddWithValue("@RESPONSE",this.rptComments.
cmd.ExecuteNonQuery(); con.Close();
} }
I am not sure what to do in the bold line.
Please help me.