November 7th, 2013, 08:51 AM
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"
<asp:ListView ID="ContactSupport" runat="server" OnPreRender="ContactSupport_PreRender">
<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>
The binding works fine for textboxes, but I could not find a way to bind data with dropdowns.
ContactSupport.DataSource = ds.Tables["Records"];
January 15th, 2014, 10:02 PM
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.
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;