PaisaFever Shakshi PaisaFever Shakshi - 7 months ago 41
ASP.NET (C#) Question

Why is this insert code inserting data twice on button clicks?

The following code inserts same data two time in database table, but I want it to insert only one item when button is clicked.

What is the problem in this code?

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click

If RadUpload1.UploadedFiles.Count >= 0 Then
Dim file As UploadedFile = RadUpload1.UploadedFiles(0)
SqlDataSource1.InsertParameters("photo").DefaultValue = "./upload/" & file.GetName()
'SqlDataSource1.InsertParameters("name").DefaultValue = TextBox1.Text
End If
End Sub


You must be using both OnClick="Button1_Click" in your markup and Handles Button1.Click in your procedure. Try removing one of them.