我正在尝试将我的评级表单插入到基于点击提交表单按钮的数据库中,但是我收到以下错误。
编译器错误消息:CS0123:' sendbtnSubmit'没有超载匹配委托' System.EventHandler'
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="kgis.aspx.cs" Inherits="portal.kgis" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<style>
.ratingStar
{
font-size: 0pt;
width: 13px;
height: 12px;
cursor: pointer;
display: block;
background-repeat: no-repeat;
}
.filledStar
{
background-image: url(images/Filled_Star.png);
}
.emptyStar
{
background-image: url(images/Empty_Star.png);
}
.savedStar
{
background-image: url(images/Saved_Star.png);
}
.auto-style1 {
height: 50px;
}
</style>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div id="popupContact">
<!-- Contact Us Form -->
<form action="#" id="feed" method="post" name="form" runat="server">
<h2>FeedBack</h2>
<hr />
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> </asp:ToolkitScriptManager>
<table style="width: 60%;">
<tr>
<td style="font-weight: bold; padding-top: 1px;">
<asp:Label ID="Label1" runat="server" Text="Name"></asp:Label>
</td>
<td>
<asp:TextBox ID="name" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td style="font-weight: bold; padding-top: 12px;">
<asp:Label ID="Label2" runat="please can anyone help me on this i want to to store the rating to databse after clicking submit (onclick) form..server" Text="E-Mail"></asp:Label>
</td>
<td>
<asp:TextBox ID="email" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" forecolor="red" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ControlToValidate="email" ErrorMessage="Input valid email!"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td style="font-weight: bold; padding-top: 28px;">
<asp:Label ID="Label3" runat="server" Text="Area"></asp:Label>
</td>
<td>
<div class="drop1">
<asp:DropDownList runat="server" ID="ddlfields">
<asp:ListItem Value="-1">--Select--</asp:ListItem>
<asp:ListItem Value="gui">GUI</asp:ListItem>
<asp:ListItem Value="coc">Correctness Of Content</asp:ListItem>
<asp:ListItem Value="sug">Suggestions</asp:ListItem>
<asp:ListItem Value="new">New Requirements</asp:ListItem>
<asp:ListItem T Value="efs">Existing Functionality Status</asp:ListItem>
</asp:DropDownList>
</div>
</td>
</tr>
<tr>
<td style="font-weight: bold; padding-top: 28px;">
<asp:Label ID="Label6" runat="server" Text="Category"></asp:Label>
</td>
<td>
<div class="drop">
<asp:DropDownList runat="server" ID="cate">
<asp:ListItem Value="-1">--Select--</asp:ListItem>
<asp:ListItem Value="Hostel">Hostel </asp:ListItem>
<asp:ListItem Value="School">School</asp:ListItem>
<asp:ListItem Value="Backwardclass">Backwardclass</asp:ListItem>
</asp:DropDownList>
</div>
</td>
</tr>
<tr>
<td style="font-weight: bold;">
<asp:Label ID="Label4" runat="server" Text="Feedback"></asp:Label>
</td>
<td>
<asp:TextBox ID="msg" runat="server" TextMode="MultiLine"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label5" runat="server" Text="Rating"></asp:Label>
</td>
<td>
<asp:Rating ID="Rating1" runat="server" StarCssClass="ratingStar" WaitingStarCssClass="savedStar"
FilledStarCssClass="filledStar" EmptyStarCssClass="emptyStar" AutoPostBack="true" MaxRating="5"
onchange="Rating1_Changed" >
</asp:Rating>
</td>
</tr>
<tr>
<td >
<asp:Label ID="lbl_point" runat="server"></asp:Label>
</td>
</tr>
</table>
<asp:Button ID="submit" runat="server" OnClick="sendbtnSubmit" Text="Send" />
</form>
</div>
</body>
</html>
using System.Data.SqlClient;
using AjaxControlToolkit;
namespace portal
{
public partial class kgis : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void sendbtnSubmit(object sender,AjaxControlToolkit.RatingEventArgs e)
{
string connectionString = "Server=KSRSAC-G2G\\SQLEXPRESS;Database=Registration;Uid=sa;Pwd=SA#123;";
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand cmd = new SqlCommand("INSERT INTO [Registration].[dbo].[FeedBack] (Name,Emailid,Category,Feedback,Area,Rate) VALUES (@Name, @Emailid,@Category,@Feedback,@Area,@Rate)");
cmd.CommandType = CommandType.Text;
cmd.Connection = connection;
cmd.Parameters.AddWithValue("@Name", name.Text);
cmd.Parameters.AddWithValue("@Emailid", email.Text);
cmd.Parameters.AddWithValue("@Category", cate.Text);
cmd.Parameters.AddWithValue("@Feedback", msg.Text);
cmd.Parameters.AddWithValue("@Area", ddlfields.Text);
cmd.Parameters.AddWithValue("@Rate", e.Value.ToString());
connection.Open();
cmd.ExecuteNonQuery();
}
}
protected void Rating1_Changed(object sender, AjaxControlToolkit.RatingEventArgs e)
{
lbl_point.Text = "You rated " + e.Value.ToString();
}
}
}
我希望在使用asp.net C#单击提交表单后将评级存储到数据库。
答案 0 :(得分:0)
更改此行:
protected void sendbtnSubmit(object sender,AjaxControlToolkit.RatingEventArgs e)
要:
protected void sendbtnSubmit(object sender,EventArgs e)
编辑:
对于您在评论中说的第二个问题,您有两个选择:
1-在Rating1_Changed事件中使用数据库。(不推荐)
2-在sendbtnSubmit事件中,而不是使用e.Value.ToString()
,使用它
myabe Rating1.CurrentRating.ToString()
答案 1 :(得分:0)
编写如下代码:
您没有在代码中使用AjaxControlToolkit.RatingEventArgs,因此不清楚它的位置。
protected void sendbtnSubmit(object sender,EventArgs e)
{
string connectionString = "Server=KSRSAC-G2G\\SQLEXPRESS;Database=Registration;Uid=sa;Pwd=SA#123;";
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand cmd = new SqlCommand("INSERT INTO [Registration].[dbo].[FeedBack] (Name,Emailid,Category,Feedback,Area,Rate) VALUES (@Name, @Emailid,@Category,@Feedback,@Area,@Rate)");
cmd.CommandType = CommandType.Text;
cmd.Connection = connection;
cmd.Parameters.AddWithValue("@Name", name.Text);
cmd.Parameters.AddWithValue("@Emailid", email.Text);
cmd.Parameters.AddWithValue("@Category", cate.Text);
cmd.Parameters.AddWithValue("@Feedback", msg.Text);
cmd.Parameters.AddWithValue("@Area", ddlfields.Text);
cmd.Parameters.AddWithValue("@Rate", e.Value.ToString());
connection.Open();
cmd.ExecuteNonQuery();
}
}
protected void Rating1_Changed(object sender, EventArgs e)
{
lbl_point.Text = "You rated " + e.Value.ToString();
}
}