Subject: listbox in edititemtemplate
Posted By: markie13 Post Date: 1/30/2004 1:35:13 PM
I have a listbox in an edititemtemplate but can't get the listbox to work. It's there, I can see it, but the scrollbar doesn't work and the selected item isn't selected (it's fed the selected items through a property in a web usercontrol).

The same usercontrol work fine when not in edit mode

Here is the usercontrol:
================================
    Public theselectedItems As String

    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
        'selectedItems = "020,009"
        bindList(theselectedItems)
    End Sub

    Sub bindList(ByVal phred As String)
        Dim ds As DataSet
        Dim sqlStr As String = "select whatever from wherever"
        ds = New DataSet
        Dim dr As DataRow
        sqlDA = New SqlDataAdapter(sqlStr, sqlConn)
        sqlDA.Fill(ds, "departments")
        lst.DataSource = ds
        lst.DataBind()
        Dim aArr As Array
        lst.Enabled = True
        aArr = Split(Trim(phred), ",")
        Dim x As Integer = 0, y As Integer = 0
        For Each dr In ds.Tables(0).Rows
            For x = 0 To UBound(aArr)
                If CStr(Trim(aArr(x))) = dr(0) Then
                    lst.Items(y).Selected = True
                End If
            Next
            'lst.Items(y).Selected = True
            y += 1
        Next
        lst.Items.Insert(0, "ALL")
    End Sub
========================================

here is the html:
========================================
    <asp:TemplateColumn HeaderText="Department(s)">
    <HeaderStyle Wrap="False"></HeaderStyle>
    <ItemTemplate>
    <asp:label Runat="server" text='<%# trim(DataBinder.Eval(Container, "DataItem.departmentSecurity")) %>'>
    </asp:label>
    <uc1:deptListBox theselectedItems='<%#trim(databinder.eval(Container, "dataitem.departmentsecurity"))%>' id="DeptListBox1" runat="server"></uc1:deptListBox>
    </ItemTemplate>
    <EditItemTemplate>
    <uc1:deptListBox theselectedItems='<%#trim(databinder.eval(Container, "dataitem.departmentsecurity"))%>' id="Deptlistbox2" runat="server"></uc1:deptListBox>
    <asp:ListBox Font-Names="verdana, arial" Font-size="10px" ID=deptList Runat=server DataTextField="departmentName" DataValueField="deptNum" Selectionmode=multiple DataSource='<%#buildDeptList(trim(databinder.eval(Container, "dataitem.departmentsecurity")))%>' Enabled="true">
    </asp:ListBox>
    </EditItemTemplate>
    </asp:TemplateColumn>
==============================================


mark




Go to topic 9204

Return to index page 959
Return to index page 958
Return to index page 957
Return to index page 956
Return to index page 955
Return to index page 954
Return to index page 953
Return to index page 952
Return to index page 951
Return to index page 950