ListView, DropdownList & DataBind

I have a form that has a Dropdown list box and few text boxes etc.
The form is inside ListView control and I am using DataBind to bind data with text boxes and drop down list.

To give you an idea, I have simplified the code and it looks like this:


              <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>

ContactSupport_PreRender code behind:


                ContactSupport.DataSource = ds.Tables["Records"];
                ContactSupport.DataBind();

Problem:
Data binding with text box controls works fine, but what should I do to bind data with dropdown list box?

Note that there are several other text boxes in the form and I just simplified the above code. A screenshot of form is attached below

Is there any solution to it?

What are you trying to bind to your DropDownList object? All you need is a collection of strings (i.e. List<String>) and to bind it like so:


    foreach (string str in stringList){
        dropDownListobject.Items.Add(new ListItem(stringList[str]));
    }

I am not trying to add items to dropdown.
Please have a look at the screenshot I attached with my question and read the details.

See the following which is what I’m assuming you’re looking for as your question was very vague, you haven’t really explained how you want to bind the data and when it’s bound.

Thanks for your response.
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

<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>
 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.