اذا ممكن عندي داتا بيس وعندي شاشة
الشاشة فيها dropdownlist وفيها text مرتبطة بياناتها في جدول واحد
اريد اني اختار من ال dropdownlist ويظهر اللي اخترته في الـ dropdownlist وال text
حيث ان الكود بهذا الشكل
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim cmd2 As String = "SELECT Floor_Code,Office_Code FROM Offices_Table WHERE Deleted_Status= 'False' Order By Floor_Code"
Me.FloorCode_DropDownList.DataValueField = "Floor_Code"
'Me.OfficeCode_TextBox.Text = "Office_Code"
BindList(cmd2, FloorCode_DropDownList)
End If
End Sub
Sub BindList(ByVal strg_cmd As String, ByVal drp As DropDownList)
Dim cmd As New SqlCommand(strg_cmd, New SqlConnection(ConfigurationManager.ConnectionStrings("strConn").ToString))
Dim dr As SqlDataReader
Try
cmd.Connection.Open()
cmd.ExecuteNonQuery()
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
drp.DataSource = dr
drp.DataBind()
dr.Close()
cmd.Connection.Close()
cmd.Connection.Dispose()
Catch ex As Exception
'MsgBox(ex.Message)
Finally
If Not dr Is Nothing Then
dr.Close()
End If
drp.Items.Insert(0, "Choose From List")
drp.SelectedIndex = 0
End Try
End Sub
Protected Sub Save_ImageButton_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles Save_ImageButton.Click
Try
Dim cmd As New SqlCommand("INSERT INTO OutLets_Table (Floor_Code,Office_Code,Outlet_V,Outlet_D,Outlet_Status,Created_By,Create_Date) VALUES('" & Me.FloorCode_DropDownList.SelectedValue & "','" & Me.OfficeCode_TextBox.Text & "','" & Me.Outlet_V_TextBox.Text & "','" & Me.Outlet_D_TextBox.Text & "','"& Me.Outlet_Status_TextBox.Text & "', '" & User.Identity.Name & "',{fn now()})", New SqlConnection(ConfigurationManager.ConnectionStrings("strConn").ToString))
cmd.Connection.Open()
cmd.ExecuteNonQuery()
cmd.Connection.Close()
cmd.Connection.Dispose()
Me.Save_ImageButton.Enabled = False
Me.Msg_Label.Visible = True
Me.Msg_Label.Text = "One Record Saved..."
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Add Error")
End Try
End Sub
فهل من معين؟؟؟؟؟؟؟؟


