禁用或启用DropDownList的Items
因为网友需要不但能禁用还能可以启用DropDownList的Items。为了不想用户写太多代码。Insus.NET写了一个类别,并让它继承了System.Web.UI.WebControls命名空间下的DropDownList. 可从下图看到InsusDropDownList实例化并传入DropDownList控件,然后实例化之后的对象,就是可以使用highlight的四个方法DisableImsByText(), DisabletemsByVue() ,EnableItemsBText(), EnableItemsByValue()。

InsusDropDownList类别:
InsusDropDownList
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
/// <summary>
/// Summary description for InsusDropDownList
/// </summary>
namespace Insus.NET
{
public class InsusDropDownList : DropDownList
{
DropDownList _DropDownList;
public InsusDropDownList(DropDownList dropDownList)
{
this._DropDownList = dropDownList;
}
public void DisableItemsByText(string text)
{
DisableItems(GetIndexByText(text));
}
public void EnableItemsByText(string text)
{
EnableItems(GetIndexByText(text));
}
public void DisableItemsByValue(string value)
{
DisableItems(GetIndexByValue(value));
}
public void EnableItemsByValue(string value)
{
EnableItems(GetIndexByValue(value));
}
private int GetIndexByText(string text)
{
return this._DropDownList.Items.IndexOf(this._DropDownList.Items.FindByText(text));
相关新闻>>
- 发表评论
-
- 最新评论 进入详细评论页>>
今日头条
更多>>您可能感兴趣的文章
- 聊聊.net程序设计——浅谈使用VS2010建模拓展(下
- MVC3+Entity Framework 实现投票系统(二)
- .net架构的最后思考(箴言)
- .NET简谈互操作(四:基础知识之Dispose非托管内存
- asp.net DataTable和Dataset序列化成Json格式
- Web Service学习笔记(4)
- 使用ASP.NET MVC3+EF+Jquery制作文字直播系统(四
- Spring MVC 3.0.5+Spring 3.0.5+MyBatis3.0.4全注
- .NET设计模式:工厂方法模式(Factory Method)[1]
- JQuery+Asp.net MVC实现用户名重名查询



