problem with dropdown list

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AhmedMahmoud
    New Member
    • Apr 2011
    • 1

    problem with dropdown list

    I have 3 textboxes (EmployeeName, EmployeeNumber, Password)
    and 2 drodownlists (Department, JobTitle)

    I made a gridview from employee table to insert data to it by clicking Submit button. Now I am facing a problem with the dropdownlist I dont know how to declare it.

    Code:
    Imports System.Data.SqlClient
    Imports System.Data
    
    Partial Class _Default
        Inherits System.Web.UI.Page
    
        Dim conn As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\USER\Desktop\WebSite5\App_Data\Database.mdf;Integrated Security=True;User Instance=True")
        Dim sqlCom As New SqlCommand
    
    
        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            conn.Open()
            sqlCom.Connection = conn
    
            sqlCom.CommandText = "insert into EmployeeTable (EmpNumber, EmpName, DepartmentName, JobTitle, Password) VALUES ('" & TextBoxEmployeeNumber.Text & "', '" & TextBoxEmployeeName.Text & "', '" & TextBoxDepartment.Text & "', '" & TextBoxJobTitle.Text & "', '" & TextBoxPassword.Text & "')"
    
            sqlCom.ExecuteNonQuery()
            conn.Close()
    
        End Sub
    End Class
    Could anyone help me with this.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Is the DropDownList part of the GridView?
    Is that why you can't get it?
    I'm not sure what you mean when you say you don't know how to declare the DropDownList.

    -Frinny

    Comment

    • aspdotnetuser
      New Member
      • Nov 2010
      • 22

      #3
      Hi,

      I am able to make that you are submitting and employee information, which reflects in the gridview after inserting into DB.

      You need to repopulate gridview values by select query from DB for every insert you do. For binding dropdown in gridview try to perform it inside "gridview_rowda tabound" event.

      aspdotnetuser

      Comment

      Working...