#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2007
    Posts
    12
    Rep Power
    0

    ListView, DropdownList & DataBind


    I am new to ASP.net and still learning different terms etc.

    This is the online form of a telephone company, where a user may request to add more than one telephone lines. The form has text boxes as well as a dropdown box.

    I am using ListView to display list of telephone line requests from a user and binding data with it on "OnPreRender"

    PHP Code:
    <asp:ListView ID="ContactSupport" runat="server" OnPreRender="ContactSupport_PreRender">
                      <
    ItemTemplate>
                          <
    tr>
                            <
    td><asp:TextBox ID="txtNetworkProvider" runat="server" Text='<%#Eval("txtNetworkProvider") %>'></asp:TextBox></td>
                            <
    td><asp:DropDownList ID="txtTypeOfLine" runat="server" >
                            <
    asp:ListItem Text="A" Value="A"></asp:ListItem>
                            <
    asp:ListItem Text="12" Value="12"></asp:ListItem>
                        </
    asp:DropDownList></td>
                          </
    tr>
                      </
    ItemTemplate>
                  </
    asp:ListView
    PHP Code:
     ContactSupport.DataSource ds.Tables["Records"];
                    
    ContactSupport.DataBind(); 
    The binding works fine for textboxes, but I could not find a way to bind data with dropdowns.

    Please help.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    16
    Rep Power
    0
    I happened to read some basic codes for listview data binding . Let me put them here for you as some kind of reference, however, they are in C#. Anyway, hope it helps.
    Code:
    this.ListView1.DataSource = dataSource;
    this.ListView1.DisplayMember = "StudentName";
    this.ListView1.ValueMember = "StudentID";
    void ListView1_ItemDataBound(object sender, WinForms.UI.ListViewItemEventArgs e)
    {
        {
            if (ketticListView1.ViewType == Kettic.WinForms.UI.ListViewType.ListView)
            {
                e.Item.Image = ((Person)e.Item.DataBoundItem).Picture;
            }
        }
    }

IMN logo majestic logo threadwatch logo seochat tools logo