Hi all, I have an ADD button that I added to a gridview, the idea is when I press the add button it adds that customer number to a dataset I have. I am not sure of what control I need to get that customer number, you can see I am trying several different ones, but NONE are correct (Cust1,2 & 3). Can someone please tell me what the correct way is for this. The gridview is made up of fields that I converted to TemplateFields, not sure if that matters or not... here is my button click event
Protected Sub BtnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim Cust1 As Integer = CInt(GridView1.DataKeys(e.
RowIndex).
Value)
Dim Cust2 As String = CType(row.FindControl("Cu_
CustomerNo
"), TextBox).Text
Dim Cust3 As TextBox = CType(e.Row.FindControl("C
u_Customer
No"), TextBox)
Dim sql1 As String = "INSERT INTO [tmpGMCCustomers] ([CustomerNumber]) VALUES (@CustomerNumber)"
Using conn As New SqlConnection(System.Confi
guration.C
onfigurati
onManager.
Connection
Strings("S
QLReportsC
orpReports
Connection
String").C
onnectionS
tring)
Dim cmd As New SqlCommand(sql1, conn)
cmd.Parameters.Add(New SqlParameter("@CustomerNum
ber", Cust))
conn.Open()
cmd.ExecuteNonQuery()
cmd.Connection.Close()
End Using
End Sub
Thanks,
Randy
Start Free Trial