本文介绍了错误是"btnSubmit_Click"不是"ASP.mycomment_aspx"的成员.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码...


html文件..

this is the my code...


html file ..

<tr>
Line 25: <td></td>
Line 26: <td><asp:Button ID="btnSubmit" runat="server" Text="Submit" onclick="btnSubmit_Click" /></td>
Line 27: </tr>
Line 28: </table>



这是vb代码



this is vb code

Protected Sub btnSubmit_Click(sender As Object, e As EventArgs)

            Dim con As New SqlConnection("Data Source=KARANDE\sqlexpress;Initial Catalog=nitink;Integrated Security=True")
            con.Open()
            Dim cmd As New SqlCommand("insert into [User] (Username,Subject,Comment,PostedDate) values(@UserName,@Subject,@Comment,@PostedDate)", con)
            cmd.Parameters.AddWithValue("@userName", txtName.Text)
            cmd.Parameters.AddWithValue("@subject", txtSubject.Text)
            cmd.Parameters.AddWithValue("@comment", txtComment.Text)
            cmd.Parameters.AddWithValue("@postedDate", DateTime.Now)
            cmd.ExecuteNonQuery()
            con.Close()
            txtName.Text = String.Empty
            txtSubject.Text = String.Empty
            txtComment.Text = String.Empty
            BindRepeaterData()
        End Sub
        Protected Sub BindRepeaterData()
            Dim con As New SqlConnection("Data Source=KARANDE\sqlexpress;Initial Catalog=nitink;Integrated Security=True")
            con.Open()
            Dim cmd As New SqlCommand("select * from [User] Order By PostedDate desc", con)
            Dim ds As New DataSet()
            Dim da As New SqlDataAdapter(cmd)
            da.Fill(ds)
            If ds.Tables(0).Rows.Count > 0 Then
                RepDetails.Visible = True
                RepDetails.DataSource = ds
                RepDetails.DataBind()
            Else
                RepDetails.Visible = False
            End If

            con.Close()
        End Sub

推荐答案

Protected Sub btnSubmit_Click(sender As Object, e As EventArgs)Handles ButtonAdd.Click

            Dim con As New SqlConnection("Data Source=KARANDE\sqlexpress;Initial Catalog=nitink;Integrated Security=True")
            con.Open()
            Dim cmd As New SqlCommand("insert into [User] (Username,Subject,Comment,PostedDate) values(@UserName,@Subject,@Comment,@PostedDate)", con)
            cmd.Parameters.AddWithValue("@userName", txtName.Text)
            cmd.Parameters.AddWithValue("@subject", txtSubject.Text)
            cmd.Parameters.AddWithValue("@comment", txtComment.Text)
            cmd.Parameters.AddWithValue("@postedDate", DateTime.Now)
            cmd.ExecuteNonQuery()
            con.Close()
            txtName.Text = String.Empty
            txtSubject.Text = String.Empty
            txtComment.Text = String.Empty
            BindRepeaterData()
        End Sub
        Protected Sub BindRepeaterData()
            Dim con As New SqlConnection("Data Source=KARANDE\sqlexpress;Initial Catalog=nitink;Integrated Security=True")
            con.Open()
            Dim cmd As New SqlCommand("select * from [User] Order By PostedDate desc", con)
            Dim ds As New DataSet()
            Dim da As New SqlDataAdapter(cmd)
            da.Fill(ds)
            If ds.Tables(0).Rows.Count > 0 Then
                RepDetails.Visible = True
                RepDetails.DataSource = ds
                RepDetails.DataBind()
            Else
                RepDetails.Visible = False
            End If

            con.Close()
        End Sub


这篇关于错误是"btnSubmit_Click"不是"ASP.mycomment_aspx"的成员.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 09:33