Hi guys. i have an editable datagrid that has a edit button next to
each record.once i click on it goes to a new page and loads the specifc record in edit mode and allow me edit the values. one of the values is in drop down box as u can see in the pic below. The problem that i have it always loads the first value from drop downlist not value coresponding to the record. I be happy if some one help me fixt this problem.thanks
http://i5.photobucket.com/albums/y18...7/datagrid.jpg (datagrid pic)
http://i5.photobucket.com/albums/y18...7/editmode.jpg (edit page)
http://i5.photobucket.com/albums/y18...designview.jpg ( edit form in deisign view)
http://i5.photobucket.com/albums/y18...7/19932c0e.jpg (db reletions)
my onload and update code :
Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
MyConnection = New SqlConnection("server=localhost;database=teniss2;uid=web;pwd=web;")
If Not IsPostBack Then
SqlSelectCommand1.Parameters(0).Value = Convert.ToInt16(Request.QueryString("match"))
SqlDataAdapter1.Fill(DataSet11, "matches")
MatchNolable.DataBind()
TeamNolable.DataBind()
TextBox1.DataBind()
TextBox2.DataBind()
SqlDataAdapter2.Fill(DataSetplayerteamMatches1, "Players")
Me.DropDownList1.DataBind()
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyCommand As SqlCommand
Dim UpdateCmd As String = "Update Matches Set Teamno=" & Me.TeamNolable.Text & ", playerno=" & Me.DropDownList1.SelectedValue & ", won=" & Me.TextBox1.Text & ", lost=" & Me.TextBox2.Text & _
" Where MatchNo = " & MatchNolable.Text
MyCommand = New SqlCommand(UpdateCmd, MyConnection)
MyCommand.Connection.Open()
MyCommand.ExecuteNonQuery()
MyCommand.Connection.Close()
Server.Transfer("teamsandmatches.aspx")
End Sub