Problem save data in datagridview with combobox (VB Net 2008)

I Use datagridview with a column its type ComboBox.I have and one command buton(save) on the form.What is the code to save data in the datagridview.
me.TableAdapter.Update(me.DataSet.Table) das not work because of the combobox i put in the datagridview column

Comments

  • seancampbellseancampbell Pennsylvania, USA
    Did you get this solved?

    In the front end, I add this property to my Gridview
    (this goes inside the ASP:GridView declaration in the front end, if you are creating you page in design view, I believe these are properties that can be set in the Properties view/control)
    [code]
    OnRowUpdating = "GridView1_RowUpdating"
    OnRowDeleting = "GridView1_Deleting"
    [/code]

    I also add this column:
    [code]






    [/code]

    In the back end, I use these functions to handle the two command buttons I have just added

    [code]
    Public Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs)

    Dim gvRow as GridViewRow = GridView1.Rows(e.RowIndex)
    'gvRow.FindControl("ControlName") 'Returns a control in that row, such as you drop down list
    'Dim DDL as DropDownList = gvRow.FindControl("DropDownList1")

    End Sub

    Public Sub GridView1_Deleting(ByVal sender As Object, ByVal e As GridViewDeleteEventArgs)
    Dim gvRow as GridViewRow = GridView1.Rows(e.RowIndex)
    'gvRow.FindControl("ControlName") 'Returns a control in that row, such as you drop down list
    'Dim DDL as DropDownList = gvRow.FindControl("DropDownList1")

    End Sub
    [/code]

    Replace GridView1 with the name of your GridView
    DropDownList1 in the commented code parts to your DropDownList's ID

    Happy Coding,
    Campbell - firesickle.com
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion