hi i have 4 DropDownList
i made connction with database sql server 2008
and create 2 button NEW , SAVE button

here funtion to DropDown
Protected Sub DropDownList_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadComboBox6.Init

    If flagNEW <> "NEW" Then

        Dim adapter As New SqlDataAdapter("SELECT  ID,DESCR , ACCT_NO,MAISTAKE_ID  FROM  HAL_HR_PENALTY_TAP ", con)
        Dim links As New DataTable()

        adapter.Fill(links)

        RadComboBox6.DataTextField = "ID"
        RadComboBox6.DataValueField = "ID"

        'TextBox6.Text = flagNEW




        RadComboBox6.DataSource = links
        RadComboBox6.DataBind()
    End If

End Sub

when i click new i make empty DropDown i fill data DropDownList

and when i click save  

 con.Close()
            con.Open()
            Dim cmd As SqlCommand
            cmd = New SqlCommand("insert into HAL_HR_PENALTY_TAP (ID,DESCR,MAISTAKE_ID,ACCT_NO) VALUES (@ID,@DESCR,@MAISTAKE_ID,@ACCT_NO)", con)
            Dim pr1 As New SqlParameter
            pr1 = cmd.Parameters.Add("@ID", SqlDbType.VarChar)
            pr1.Value = RadComboBox6.Text
            pr1 = cmd.Parameters.Add("@DESCR", SqlDbType.VarChar)
            pr1.Value = RadComboBox7.Text
            pr1 = cmd.Parameters.Add("@MAISTAKE_ID", SqlDbType.VarChar)
            pr1.Value = Left(RadComboBox8.Text, 2)
            pr1 = cmd.Parameters.Add("@ACCT_NO", SqlDbType.VarChar)
            pr1.Value = RadComboBox9.Text
            'con.Open()


            cmd.ExecuteNonQuery()

            MsgBox("تم الحفظ")

it saved but the problem the data not back when i DropDownList

give me empty List how i refrish data in DropDownList after save

If I'm imagine the problem right, I would fill the dropdownlists at page_load by calling the DropDownList_Init, and then when a saving gets succeded, I would use postback. Like this:

try
{
con.open();
cmd.ExecuteNonQuery();
}
catch
{
MsgBox("Error")
}
finally
{
Response.Redirect(Request.RawUrl);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.