Data-bound Controls Liisview website link Management

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.