Datalist EditItem ListBox issues

In the CMS project I am actually building, I have a Datalist with some CRUD manage inline.

I use an EditItem template, and some controls. One of the control is a Listbox.

Sadly, I was not able from my code to read correctly the values of the ListBox on a DataList Update event.

I casted the Listbox like that:

Dim MyList as Listbox=ctype(MyDatalist.Controls.item(e.Item.ItemIndex).FindControl("MyListBox"), ListBox)

Nothing works.

The only way I found is to come back to an 'old' classic Request.Form like that:

Dim MyList as string = Request.Form(6)


Why 6 ? Because it's the actual index in my controls list.

I know, you can say why not using Request.Form("MyListBox")

Well for me it doesn't works :-(

Some thoughts ?


 

1 Comment

  • Try this:



    ---------------------

    DataList.DataSource = DSDataList

    DataList.DataBind()



    For I = 0 To DataList.Items.Count - 1



    Dim dgi As DataListItem = DataList.Items(DataList.Items(I).ItemIndex)

    Dim TMPList As ListBox = DirectCast(dgi.FindControl("MyList"), ListBox)



    TMPList.DataSource = DS

    TMPList.DataTextField = "TEXT"

    TMPList.DataValueField = "ID"

    TMPList.DataBind()



    Next

    ------------------

Comments have been disabled for this content.