waterhidden
asked on
getting SelectedValue of a DropDownList in a DataGrid
i create my dropdownlist in ItemDataBound:
Dim drp As New DropDownList
'fill dropdownlist...
drp.ID = "drp" 'this works (when i view source of html page, i see this id)
e.Item.Cells(3).Controls.A dd(drp)
then i wanna get selectedvalue of this dropdownlist:
Dim drop As New DropDownList
drop = CType(Me.SiparisSepet.Item s(i).Cells (3).FindCo ntrol("drp "), DropDownList) 'when trace in on this line, drop's value is NOTHING!!
Dim yetkiliKod As String = drop.SelectedValue.ToStrin g 'trace breaks on this line and the error is: "Object reference not set to an instance of an object."
is there any way to reach the selectedvalue of a dropdownlist in a datagirid which is created in ITEMDATABOUND?
waiting for any help, thanx..
Dim drp As New DropDownList
'fill dropdownlist...
drp.ID = "drp" 'this works (when i view source of html page, i see this id)
e.Item.Cells(3).Controls.A
then i wanna get selectedvalue of this dropdownlist:
Dim drop As New DropDownList
drop = CType(Me.SiparisSepet.Item
Dim yetkiliKod As String = drop.SelectedValue.ToStrin
is there any way to reach the selectedvalue of a dropdownlist in a datagirid which is created in ITEMDATABOUND?
waiting for any help, thanx..
ASKER
yes, datagrid binds in page load, in "If Not Page.IsPostBack"
any other ideas?
post your code
ASKER
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.msg.Text = ""
Dim Funcs As New Functions
If Not Page.IsPostBack Then
'FillPers()
Me.perKod.Text = "00700178"
Me.malzemeKategori.Text = Funcs.FillMalzemeKategori( Me.MyConn, Me.MyComm)
FillMalKat()
Me.SiparisSepet.DataSource = (ListTaleps(Me.perKod.Text ))
Me.SiparisSepet.DataBind()
End If
Me.siparisSepeti.Text = Funcs.FillSiparisSepeti(Me .MyConn, Me.MyComm, Me.perKod.Text)
Me.favorilerim.Text = Funcs.FillFavoriListesi(Me .MyConn, Me.MyComm, Me.perKod.Text)
End Sub
Private Sub SiparisSepet_ItemDataBound (ByVal sender As Object, ByVal e As System.Web.UI.WebControls. DataGridIt emEventArg s) Handles SiparisSepet.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingIt em Then
If e.Item.Cells(0).Text = "0" Or e.Item.Cells(0).Text = "1" Then
e.Item.Cells(3).ColumnSpan = CInt(e.Item.Cells.Count)
For i = e.Item.Cells.Count - 1 To 0 Step -1
If i <> 3 And i <> 1 And i <> 0 And i <> 2 Then
e.Item.Cells.RemoveAt(i)
End If
Next
e.Item.Cells(0).Visible = False
e.Item.Cells(1).Visible = False
e.Item.Cells(2).Visible = False
j += 1
e.Item.Cells(3).BackColor = Color.LightBlue
Dim lbl1 As New Label
Dim lbl2 As New Label
Dim lbl3 As New Label
lbl1.Text = "<table border=""1"" cellpadding=""0"" cellspacing=""0"" style=""border-collapse: collapse"" bordercolor=""#C0C0C0"" width=""100%""><tr><td>" & _
"<table border=""0"" cellpadding=""0"" cellspacing=""0"" style=""border-collapse: collapse"" bordercolor=""#C0C0C0"" width=""100%"">" & _
"<tr>" & _
"<td width=""30%"" rowspan=""2"">" & j & ".<font color=""#808080""><i> " & e.Item.Cells(2).Text & "</i></font></td>" & _
"<td width=""15%""><font color=""#808080""><i>Yetki li:</i></f ont></td>" & _
"<td width=""55%"" align=""right"">"
lbl2.Text = "</td></tr><tr><td width=""15%""><font color=""#808080""><i>Maliy et Merkezi:</i></font></td><t d width=""55%"" align=""right"">"
lbl3.Text = "</td> </tr> </table> </td> </tr> </table>"
'YETKILI DROPDOWNLIST
Dim drp As New DropDownList
MyConn.Open()
If e.Item.Cells(0).Text = "1" Then
MyComm.CommandText = "SELECT FATURA.GEN60PERSORG.PERSKO D, FATURA.GEN60PERSORG.PERSAD FROM ORGAGRUPDETAY" & _
"2, GEN81WORKFLOWGRUP2, FATURA.GEN60PERSORG WHERE ORGAGRUPDETAY2.GRPKOD = GEN81WO" & _
"RKFLOWGRUP2.WFGRPKOD AND ORGAGRUPDETAY2.PERSKOD = FATURA.GEN60PERSORG.PERSKO D AN" & _
"D (GEN81WORKFLOWGRUP2.PROGRA M = 'ETALEP') AND (GEN81WORKFLOWGRUP2.GRPKOD = '" & e.Item.Cells(1).Text & "'" & _
") AND (GEN81WORKFLOWGRUP2.WFSIRA = 1) AND (FATURA.GEN60PERSORG.ORGKA DEME IN ('" & _
"ORG', 'BOS')) AND (FATURA.GEN60PERSORG.ORGSE VIYE = 0)"
ElseIf e.Item.Cells(0).Text = "0" Then
MyComm.CommandText = "SELECT EXPR1, EXPR2 FROM ((SELECT FATURA.GEN60PERSORG.PERSKO D AS EXPR1, FATURA.GE" & _
"N60PERSORG.PERSAD AS EXPR2 FROM ORGAGRUPDETAY2, GEN82WORKFLOWGRUP2, FATURA.GEN60" & _
"PERSORG WHERE ORGAGRUPDETAY2.GRPKOD = GEN82WORKFLOWGRUP2.WFGRPKO D AND ORGAGRUPDE" & _
"TAY2.PERSKOD = FATURA.GEN60PERSORG.PERSKO D AND (GEN82WORKFLOWGRUP2.PROGRA M = 'ET" & _
"ALEP') AND (GEN82WORKFLOWGRUP2.MALKOD = '" & e.Item.Cells(1).Text & "') AND (GEN82WORKFLOWGRUP2.WFSIRA =" & _
" 1) AND (FATURA.GEN60PERSORG.ORGKA DEME IN ('ORG', 'BOS')) AND (FATURA.GEN60PERSO" & _
"RG.ORGSEVIYE = 0)) UNION (SELECT '0' AS EXPR1, 'SATINALMA' AS EXPR2 FROM GEN82WO" & _
"RKFLOWGRUP2 WHERE MALKOD = '" & e.Item.Cells(1).Text & "' AND WFGRPKOD = '-')) DERIVEDTBL"
End If
Dim rdr As OleDb.OleDbDataReader = MyComm.ExecuteReader
k = 0
While rdr.Read
drp.Items.Add(rdr.Item(1))
drp.Items(k).Value = rdr.Item(0)
k += 1
End While
rdr.Close()
'MALIYET MERKEZI DROPDOWNLIST
Dim drp2 As New DropDownList
MyComm.CommandText = "SELECT EL3_CODE MMCODE, EL3_NAME MMNAME FROM OASKOC.OAS_EL3_ELEMENT " & _
"WHERE (EL3_CMPCODE = '010') AND (EL3_CODE LIKE '3%') ORDER BY MMNAME"
Dim rdr2 As OleDb.OleDbDataReader = MyComm.ExecuteReader
k = 0
While rdr2.Read
drp2.Items.Add(rdr2.Item(1 ))
drp2.Items(k).Value = rdr2.Item(0)
k += 1
End While
rdr2.Close()
drp.ID = "drp"
drp.Attributes.Add("Runat" , "Server")
drp.DataBind()
drp2.ID = "drp2"
MyComm.CommandText = "SELECT FATURA.HUS_RIGHT('00000000 00' || NVL(MALIYETMERKEZI, 'Tnmsz'), 5) AS MALIYETMERKEZI " & _
"FROM FATURA.GEN60PERSONEL WHERE (LOGONUSER = '" & UCase(Request.ServerVariab les("REMOT E_USER").R eplace("i" , "I")) & "') " & _
"GROUP BY MALIYETMERKEZI"
Dim rdr3 As OleDb.OleDbDataReader = MyComm.ExecuteReader
Dim mmerkezi As String
While rdr3.Read
mmerkezi = rdr3.Item(0)
End While
rdr3.Close()
'If Not mmerkezi = "Tnmsz" Then
' drp2.Items.FindByValue(mme rkezi).Sel ected = True
'End If
MyConn.Close()
e.Item.Cells(3).Controls.A dd(lbl1)
e.Item.Cells(3).Controls.A dd(drp)
e.Item.Cells(3).Controls.A dd(lbl2)
e.Item.Cells(3).Controls.A dd(drp2)
e.Item.Cells(3).Controls.A dd(lbl3)
'CType(e.Item.Cells(3).Con trols(3), HtmlControls.HtmlInputHidd en).Value = "drp" 'e.Item.Cells(3).Controls( 3).UniqueI D()
'e.Item.Cells(3).Controls( 1).Visible = False
Else
e.Item.Cells(4).Text = "<a href=""javascript:popupPag e('Malzeme Ayrinti.as px?mamulKo d=" & e.Item.Cells(3).Text & "',1)"">" & e.Item.Cells(4).Text & "</a>"
e.Item.Cells(0).Visible = False
e.Item.Cells(1).Visible = False
e.Item.Cells(2).Visible = False
e.Item.Cells(3).Visible = False
End If
ElseIf e.Item.ItemType = ListItemType.Header Then
e.Item.Cells(0).Visible = False
e.Item.Cells(1).Visible = False
e.Item.Cells(2).Visible = False
e.Item.Cells(3).Visible = False
ElseIf e.Item.ItemType = ListItemType.Footer Then
e.Item.Cells(0).ColumnSpan = CInt(e.Item.Cells.Count)
e.Item.Cells(0).Text = "<font color = ""red"">Talep Sepetinizdeki Malzemeler " & j & " Farklý Talepe Dönüþmüþtür. Onaylýyorsanýz 'Devam' Tuþuna Basýnýz. Talep(ler) Ýþleme Alýnacaktýr.</font>"
For i = e.Item.Cells.Count - 1 To 1 Step -1
e.Item.Cells.RemoveAt(i)
Next
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'Dim aaa As String = (CType(Me.SiparisSepet.Ite ms(1).Find Control("d rp"), DropDownList).SelectedItem .Value).To String
Dim Funcs As New Functions
Dim talepID, tempGrpKod, yetkiliKod, grpKod As String
Dim arr As New ArrayList
Dim arr2 As New ArrayList
MyConn.Open()
MyComm.CommandText = "SELECT MAMULKOD, GRPKOD, BIRIM FROM TEMPTALEP WHERE PERSKOD = '" & Me.perKod.Text & "' AND KATEGORI = '0'"
Dim rdr1 As OleDb.OleDbDataReader = MyComm.ExecuteReader
If rdr1.HasRows Then
While rdr1.Read
arr.Add(rdr1.Item(0))
arr2.Add(rdr1.Item(2))
grpKod = rdr1.Item(1)
End While
MyComm2.CommandText = "SELECT MAX(SIPARISKOD) FROM SIPARISLER"
MyConn2.Open()
Dim rdr2 As OleDb.OleDbDataReader = MyComm2.ExecuteReader
While rdr2.Read
talepID = Funcs.StringIncreaser(rdr2 .Item(0).T oString)
End While
rdr2.Close()
'INSERT INTO SIPARISLER
MyComm2.CommandText = "INSERT INTO SIPARISLER (SIPARISKOD, PERSKOD, SIPTARIH, ACIL, ONAY, AKTIF) VALUES " & _
"('" & talepID & "', '" & Me.perKod.Text & "', TO_DATE('" & Date.Now.ToString & "', 'DD/MM/YYYY HH24:MI:SS'), '0', '0', '1')"
Dim rdr3 As OleDb.OleDbDataReader = MyComm2.ExecuteReader
rdr3.Close()
'INSERT ARR() INTO SIPARISAYRINTI
For i = 0 To arr.Count - 1
MyComm2.CommandText = "INSERT INTO SIPARISAYRINTI (SIPARISKOD, MAMULKOD, BIRIM, DURUM, ONAY) VALUES " & _
"('" & talepID & "', '" & arr.Item(i) & "', '" & arr2.Item(i) & "', '0', '0')"
Dim rdr4 As OleDb.OleDbDataReader = MyComm2.ExecuteReader
rdr4.Close()
Next
'INSERT INTO SIPARISDURUM
MyComm2.CommandText = "SELECT WFKOD, WFSIRA, WFGRPKOD FROM GEN81WORKFLOWGRUP2 WHERE (PROGRAM = 'ETALEP')" & _
" AND (GRPKOD = '" & grpKod & "') ORDER BY WFKOD"
Dim rdr5 As OleDb.OleDbDataReader = MyComm2.ExecuteReader
While rdr5.Read
'****************NE YAP NE ET BU DROPDOWNA ULAS!!
If rdr5.Item(1) = "1" Then
For i = 0 To Me.SiparisSepet.Items.Coun t - 1
If Me.SiparisSepet.Items(i).C ells(0).Te xt = "1" Then
Dim drp As New DropDownList
drp = CType(Me.SiparisSepet.Item s(i).Cells (3).FindCo ntrol("drp "), DropDownList)
'yetkiliKod = CType(Me.SiparisSepet.Item s(i).Cells (3).Contro ls(0), HtmlControls.HtmlInputHidd en).Value
yetkiliKod = drp.SelectedValue.ToString '*************** HERE DFIALA13 ****************
'yetkiliKod = (CType(Me.SiparisSepet.Ite ms(i).Cell s(3).FindC ontrol("dr p"), DropDownList).SelectedItem .Value).To String
'yetkiliKod = Me.SiparisSepet.Items(i).C ontrols(1) .ID
End If
Next
Else
yetkiliKod = "-"
End If
'yetkiliKod = "?"
MyConn3.Open()
MyComm3.CommandText = "INSERT INTO SIPARISDURUM (SIPARISKOD, ADIM, YETKILIKOD, TARIH, DURUM, ONAY) VALUES " & _
"('" & talepID & "', '" & rdr5.Item(0) & "', '" & yetkiliKod & "', TO_DATE('" & Date.Now.ToString & "', 'DD/MM/YYYY HH24:MI:SS'), '0', '0')"
Dim rdr6 As OleDb.OleDbDataReader = MyComm3.ExecuteReader
rdr6.Close()
MyConn3.Close()
End While
rdr5.Close()
MyConn2.Close()
End If
rdr1.Close()
MyConn.Close()
Response.Redirect("Message .aspx?msg= 1")
End Sub
Me.msg.Text = ""
Dim Funcs As New Functions
If Not Page.IsPostBack Then
'FillPers()
Me.perKod.Text = "00700178"
Me.malzemeKategori.Text = Funcs.FillMalzemeKategori(
FillMalKat()
Me.SiparisSepet.DataSource
Me.SiparisSepet.DataBind()
End If
Me.siparisSepeti.Text = Funcs.FillSiparisSepeti(Me
Me.favorilerim.Text = Funcs.FillFavoriListesi(Me
End Sub
Private Sub SiparisSepet_ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingIt
If e.Item.Cells(0).Text = "0" Or e.Item.Cells(0).Text = "1" Then
e.Item.Cells(3).ColumnSpan
For i = e.Item.Cells.Count - 1 To 0 Step -1
If i <> 3 And i <> 1 And i <> 0 And i <> 2 Then
e.Item.Cells.RemoveAt(i)
End If
Next
e.Item.Cells(0).Visible = False
e.Item.Cells(1).Visible = False
e.Item.Cells(2).Visible = False
j += 1
e.Item.Cells(3).BackColor = Color.LightBlue
Dim lbl1 As New Label
Dim lbl2 As New Label
Dim lbl3 As New Label
lbl1.Text = "<table border=""1"" cellpadding=""0"" cellspacing=""0"" style=""border-collapse: collapse"" bordercolor=""#C0C0C0"" width=""100%""><tr><td>" & _
"<table border=""0"" cellpadding=""0"" cellspacing=""0"" style=""border-collapse: collapse"" bordercolor=""#C0C0C0"" width=""100%"">" & _
"<tr>" & _
"<td width=""30%"" rowspan=""2"">" & j & ".<font color=""#808080""><i> " & e.Item.Cells(2).Text & "</i></font></td>" & _
"<td width=""15%""><font color=""#808080""><i>Yetki
"<td width=""55%"" align=""right"">"
lbl2.Text = "</td></tr><tr><td width=""15%""><font color=""#808080""><i>Maliy
lbl3.Text = "</td> </tr> </table> </td> </tr> </table>"
'YETKILI DROPDOWNLIST
Dim drp As New DropDownList
MyConn.Open()
If e.Item.Cells(0).Text = "1" Then
MyComm.CommandText = "SELECT FATURA.GEN60PERSORG.PERSKO
"2, GEN81WORKFLOWGRUP2, FATURA.GEN60PERSORG WHERE ORGAGRUPDETAY2.GRPKOD = GEN81WO" & _
"RKFLOWGRUP2.WFGRPKOD AND ORGAGRUPDETAY2.PERSKOD = FATURA.GEN60PERSORG.PERSKO
"D (GEN81WORKFLOWGRUP2.PROGRA
") AND (GEN81WORKFLOWGRUP2.WFSIRA
"ORG', 'BOS')) AND (FATURA.GEN60PERSORG.ORGSE
ElseIf e.Item.Cells(0).Text = "0" Then
MyComm.CommandText = "SELECT EXPR1, EXPR2 FROM ((SELECT FATURA.GEN60PERSORG.PERSKO
"N60PERSORG.PERSAD AS EXPR2 FROM ORGAGRUPDETAY2, GEN82WORKFLOWGRUP2, FATURA.GEN60" & _
"PERSORG WHERE ORGAGRUPDETAY2.GRPKOD = GEN82WORKFLOWGRUP2.WFGRPKO
"TAY2.PERSKOD = FATURA.GEN60PERSORG.PERSKO
"ALEP') AND (GEN82WORKFLOWGRUP2.MALKOD
" 1) AND (FATURA.GEN60PERSORG.ORGKA
"RG.ORGSEVIYE = 0)) UNION (SELECT '0' AS EXPR1, 'SATINALMA' AS EXPR2 FROM GEN82WO" & _
"RKFLOWGRUP2 WHERE MALKOD = '" & e.Item.Cells(1).Text & "' AND WFGRPKOD = '-')) DERIVEDTBL"
End If
Dim rdr As OleDb.OleDbDataReader = MyComm.ExecuteReader
k = 0
While rdr.Read
drp.Items.Add(rdr.Item(1))
drp.Items(k).Value = rdr.Item(0)
k += 1
End While
rdr.Close()
'MALIYET MERKEZI DROPDOWNLIST
Dim drp2 As New DropDownList
MyComm.CommandText = "SELECT EL3_CODE MMCODE, EL3_NAME MMNAME FROM OASKOC.OAS_EL3_ELEMENT " & _
"WHERE (EL3_CMPCODE = '010') AND (EL3_CODE LIKE '3%') ORDER BY MMNAME"
Dim rdr2 As OleDb.OleDbDataReader = MyComm.ExecuteReader
k = 0
While rdr2.Read
drp2.Items.Add(rdr2.Item(1
drp2.Items(k).Value = rdr2.Item(0)
k += 1
End While
rdr2.Close()
drp.ID = "drp"
drp.Attributes.Add("Runat"
drp.DataBind()
drp2.ID = "drp2"
MyComm.CommandText = "SELECT FATURA.HUS_RIGHT('00000000
"FROM FATURA.GEN60PERSONEL WHERE (LOGONUSER = '" & UCase(Request.ServerVariab
"GROUP BY MALIYETMERKEZI"
Dim rdr3 As OleDb.OleDbDataReader = MyComm.ExecuteReader
Dim mmerkezi As String
While rdr3.Read
mmerkezi = rdr3.Item(0)
End While
rdr3.Close()
'If Not mmerkezi = "Tnmsz" Then
' drp2.Items.FindByValue(mme
'End If
MyConn.Close()
e.Item.Cells(3).Controls.A
e.Item.Cells(3).Controls.A
e.Item.Cells(3).Controls.A
e.Item.Cells(3).Controls.A
e.Item.Cells(3).Controls.A
'CType(e.Item.Cells(3).Con
'e.Item.Cells(3).Controls(
Else
e.Item.Cells(4).Text = "<a href=""javascript:popupPag
e.Item.Cells(0).Visible = False
e.Item.Cells(1).Visible = False
e.Item.Cells(2).Visible = False
e.Item.Cells(3).Visible = False
End If
ElseIf e.Item.ItemType = ListItemType.Header Then
e.Item.Cells(0).Visible = False
e.Item.Cells(1).Visible = False
e.Item.Cells(2).Visible = False
e.Item.Cells(3).Visible = False
ElseIf e.Item.ItemType = ListItemType.Footer Then
e.Item.Cells(0).ColumnSpan
e.Item.Cells(0).Text = "<font color = ""red"">Talep Sepetinizdeki Malzemeler " & j & " Farklý Talepe Dönüþmüþtür. Onaylýyorsanýz 'Devam' Tuþuna Basýnýz. Talep(ler) Ýþleme Alýnacaktýr.</font>"
For i = e.Item.Cells.Count - 1 To 1 Step -1
e.Item.Cells.RemoveAt(i)
Next
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'Dim aaa As String = (CType(Me.SiparisSepet.Ite
Dim Funcs As New Functions
Dim talepID, tempGrpKod, yetkiliKod, grpKod As String
Dim arr As New ArrayList
Dim arr2 As New ArrayList
MyConn.Open()
MyComm.CommandText = "SELECT MAMULKOD, GRPKOD, BIRIM FROM TEMPTALEP WHERE PERSKOD = '" & Me.perKod.Text & "' AND KATEGORI = '0'"
Dim rdr1 As OleDb.OleDbDataReader = MyComm.ExecuteReader
If rdr1.HasRows Then
While rdr1.Read
arr.Add(rdr1.Item(0))
arr2.Add(rdr1.Item(2))
grpKod = rdr1.Item(1)
End While
MyComm2.CommandText = "SELECT MAX(SIPARISKOD) FROM SIPARISLER"
MyConn2.Open()
Dim rdr2 As OleDb.OleDbDataReader = MyComm2.ExecuteReader
While rdr2.Read
talepID = Funcs.StringIncreaser(rdr2
End While
rdr2.Close()
'INSERT INTO SIPARISLER
MyComm2.CommandText = "INSERT INTO SIPARISLER (SIPARISKOD, PERSKOD, SIPTARIH, ACIL, ONAY, AKTIF) VALUES " & _
"('" & talepID & "', '" & Me.perKod.Text & "', TO_DATE('" & Date.Now.ToString & "', 'DD/MM/YYYY HH24:MI:SS'), '0', '0', '1')"
Dim rdr3 As OleDb.OleDbDataReader = MyComm2.ExecuteReader
rdr3.Close()
'INSERT ARR() INTO SIPARISAYRINTI
For i = 0 To arr.Count - 1
MyComm2.CommandText = "INSERT INTO SIPARISAYRINTI (SIPARISKOD, MAMULKOD, BIRIM, DURUM, ONAY) VALUES " & _
"('" & talepID & "', '" & arr.Item(i) & "', '" & arr2.Item(i) & "', '0', '0')"
Dim rdr4 As OleDb.OleDbDataReader = MyComm2.ExecuteReader
rdr4.Close()
Next
'INSERT INTO SIPARISDURUM
MyComm2.CommandText = "SELECT WFKOD, WFSIRA, WFGRPKOD FROM GEN81WORKFLOWGRUP2 WHERE (PROGRAM = 'ETALEP')" & _
" AND (GRPKOD = '" & grpKod & "') ORDER BY WFKOD"
Dim rdr5 As OleDb.OleDbDataReader = MyComm2.ExecuteReader
While rdr5.Read
'****************NE YAP NE ET BU DROPDOWNA ULAS!!
If rdr5.Item(1) = "1" Then
For i = 0 To Me.SiparisSepet.Items.Coun
If Me.SiparisSepet.Items(i).C
Dim drp As New DropDownList
drp = CType(Me.SiparisSepet.Item
'yetkiliKod = CType(Me.SiparisSepet.Item
yetkiliKod = drp.SelectedValue.ToString
'yetkiliKod = (CType(Me.SiparisSepet.Ite
'yetkiliKod = Me.SiparisSepet.Items(i).C
End If
Next
Else
yetkiliKod = "-"
End If
'yetkiliKod = "?"
MyConn3.Open()
MyComm3.CommandText = "INSERT INTO SIPARISDURUM (SIPARISKOD, ADIM, YETKILIKOD, TARIH, DURUM, ONAY) VALUES " & _
"('" & talepID & "', '" & rdr5.Item(0) & "', '" & yetkiliKod & "', TO_DATE('" & Date.Now.ToString & "', 'DD/MM/YYYY HH24:MI:SS'), '0', '0')"
Dim rdr6 As OleDb.OleDbDataReader = MyComm3.ExecuteReader
rdr6.Close()
MyConn3.Close()
End While
rdr5.Close()
MyConn2.Close()
End If
rdr1.Close()
MyConn.Close()
Response.Redirect("Message
End Sub
OK,
This is one of those situations when you need to rebind your datagrid in order to access the values of the dynamic controls. The value of the control will be preserved when you post back, but if you haven't re-created the dyanmic control you can't get it using the method you are using.
You have 3 choices to get the values:
1) rebind the grid then read the data using the method you are attempting
2) read the values out of Request.Form() using the control names -- if you don't need to recreate the grid, this might the way to go.
3) create a templated column to hold the combo box, which will preserve the control structure as well as the values between postbacks
This is one of those situations when you need to rebind your datagrid in order to access the values of the dynamic controls. The value of the control will be preserved when you post back, but if you haven't re-created the dyanmic control you can't get it using the method you are using.
You have 3 choices to get the values:
1) rebind the grid then read the data using the method you are attempting
2) read the values out of Request.Form() using the control names -- if you don't need to recreate the grid, this might the way to go.
3) create a templated column to hold the combo box, which will preserve the control structure as well as the values between postbacks
ASKER
i thought to create a templated column to hold the combo box, but this will make me lost time.
i don't need to rebind the grid, even it does not work.
can you tell more about 2)
i don't need to rebind the grid, even it does not work.
can you tell more about 2)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you dfiala13,
the datagrid creates coloumns at run time. so that i thought to create a templated column to hold the combo box, will make me lost time. but anyway,
Dim sVal = Request.Form("SiparisSepet :_ctl2:drp ")
worked. thank you again..
the datagrid creates coloumns at run time. so that i thought to create a templated column to hold the combo box, will make me lost time. but anyway,
Dim sVal = Request.Form("SiparisSepet
worked. thank you again..
Do you have the the code to bind the grid in am if statement
If Not Page.IsPostBack then
'fill gird
End if
Page Load is called every time you post back. If you haven't wrapped your bidinging code it will rebind the grid and wipe out any selections.
But otherwise that is exactly how you retrieve a control value from a grid.