Client code:
<%@ page language= "C #" autoeventwireup= "true" codebehind= "FriendLinks.aspx.cs" inherits= " The bindings for the ListView control. Friendlinks "%><! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
Service-Side code:
Using system;using system.collections.generic;using system.linq;using system.web;using System.Web.UI;using System.web.ui.webcontrols;using the System.data;namespace ListView control's binding {public partial class FriendLinks:System.Web.UI. Page {protected void Page_Load (object sender, EventArgs e) {} protected void Listview1_it Eminserting (object sender, Listviewinserteventargs e) {if (IsValid) {DropDown List Ddllinktype = (DropDownList) e.item.findcontrol ("DropDownList1"); e.values["linktype"] = Ddllinktype.selectedvalue; }} protected void Listview1_itemcreated (object sender, ListViewItemEventArgs e) { if (E.item.itemtype = = Listviewitemtype.insertitem) {DropDownList Ddllinktype = (Dropdownli ST) E.item.findcontrol ("DropDownList1"); TextBox txtbox = (textbox) E.item.findcontrol ("Logeurltextbox"); if (Ddllinktype = null && txtbox! = null) {ddllinktype.attributes["onchange"] = " Onlinktypechange (This, ' "+ Txtbox.clientid +" ') ";//I do not know why add this sentence can not insert if (Ddllinktype.selectedvalue = =" T Ext ") {ddllinktype.attributes[" display "] =" none "; }}}} protected void Listview1_itemupdating (object sender, Listvi Ewupdateeventargs e) {DropDownList Ddllinktype = (DropDownList) Listview1.items[e.itemindex]. FindControl ("DropDownList1"); e.newvalues["linktype"] = Ddllinktype.selectedvalue; } protected void Listview1_itemdatabound (object sender, ListViewItemEventArgs e) {if (e.item.ite Mtype = = Listviewitemtype.dataitem) {DropDownList Ddllinktype = (DropDownList) e.item.findcontr OL ("DropDownList1"); Listviewdataitem Lvdi = (ListViewdataitem) E.item; DataRowView links = (DataRowView) lvdi. DataItem; if (Ddllinktype! = null && links!=null) {var link = (ListView control's binding. Dal.data Setlinks.t_linksrow) links. Row; Ddllinktype.selectedvalue = link. Linktype; } } } }}