S
Stephan
Hi,
I'm working on a page with multiple Datalist-controls on it. The
problem I'm facing is that when I try to update a record, the
ItemIndex returns a value which is one lower than the Item I want to
edit, so when I update the record, the previous record is changed. I
put some code here, but not all. Adding, of
course, is no problem because then the index is set to -1. I tried to
use the DataKeyField property in my controls, but that doesn't work
either. I've the feeling that I terribly overlooking something. What
am I doing wrong?
Thx in advance
If Not Page.IsPostBack Then
BindData()
End If
Private Function BindData()
Dim dsSubDoelen As DataSet = objDoelen.SelectSTBSubDoelen("")
Dim dsDoelen As DataSet = objDoelen.SelectSTBDoelen("")
Dim dsGedrag As DataSet = objDoelen.SelectGedrag("")
Dim dsMethodiek As DataSet = objDoelen.SelectMethodiek("")
dlSTBDoelen.DataSource = dsDoelen
dlSTBDoelen.DataBind()
dlSTBSubDoelen.DataSource = dsSubDoelen
dlSTBSubDoelen.DataBind()
dlGedrag.DataSource = dsGedrag
dlGedrag.DataBind()
dlMethodiek.DataSource = dsMethodiek
dlMethodiek.DataBind()
End Function
Private Sub dlSTBSubDoelen_EditCommand(ByVal source As Object,
ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles
dlSTBSubDoelen.EditCommand
Mode.Value = "Edit"
dlSTBSubDoelen.EditItemIndex = CInt(e.Item.ItemIndex) <--
return a value which is one to low
BindData()
End Sub
I'm working on a page with multiple Datalist-controls on it. The
problem I'm facing is that when I try to update a record, the
ItemIndex returns a value which is one lower than the Item I want to
edit, so when I update the record, the previous record is changed. I
put some code here, but not all. Adding, of
course, is no problem because then the index is set to -1. I tried to
use the DataKeyField property in my controls, but that doesn't work
either. I've the feeling that I terribly overlooking something. What
am I doing wrong?
Thx in advance
If Not Page.IsPostBack Then
BindData()
End If
Private Function BindData()
Dim dsSubDoelen As DataSet = objDoelen.SelectSTBSubDoelen("")
Dim dsDoelen As DataSet = objDoelen.SelectSTBDoelen("")
Dim dsGedrag As DataSet = objDoelen.SelectGedrag("")
Dim dsMethodiek As DataSet = objDoelen.SelectMethodiek("")
dlSTBDoelen.DataSource = dsDoelen
dlSTBDoelen.DataBind()
dlSTBSubDoelen.DataSource = dsSubDoelen
dlSTBSubDoelen.DataBind()
dlGedrag.DataSource = dsGedrag
dlGedrag.DataBind()
dlMethodiek.DataSource = dsMethodiek
dlMethodiek.DataBind()
End Function
Private Sub dlSTBSubDoelen_EditCommand(ByVal source As Object,
ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles
dlSTBSubDoelen.EditCommand
Mode.Value = "Edit"
dlSTBSubDoelen.EditItemIndex = CInt(e.Item.ItemIndex) <--
return a value which is one to low
BindData()
End Sub