复制代码 代码如下:
/// <summary>
/// 单选按钮列
/// </summary>
/// <remarks>
/// 如果没有设置GroupName,则使用GridView的ID作为GroupName
/// 如果没有设置DataField,则使用RowIndex作为Value
/// 允许设置DataFormatString格式化数据
/// </remarks>
[AspNetHostingPermission(SecurityAction.Demand,
Level = AspNetHostingPermissionLevel.Minimal)]
public class RadioButtonSelectField : DataControlField
{
/// <summary>
/// 单选按钮组名,默认去GridView的ClientID
/// </summary>
[Description("单选按钮组名,默认去GridView的ClientID")]
public string RadioButtonGroupName
{
get
{
return this.ViewState["RadioButtonGroupName"] as string;
}
set
{
this.ViewState["RadioButtonGroupName"] = value;
}
}
/// <summary>
/// 单选按钮的样式
/// </summary>
[Description("单选按钮的样式")]
public string RadioButtonCssClass
{
get
{
return this.ViewState["RadioButtonCssClass"] as string;
}
set
{
this.ViewState["RadioButtonCssClass"] = value;
}
}
/// <summary>
/// 要绑定的数据表达式
/// </summary>
[Description("要绑定的数据表达式")]
public string DataField
{
get
{
return this.ViewState["DataField"] as string;
}
set
{
this.ViewState["DataField"] = value;
}
}
/// <summary>
/// 要绑定的数据表达式格式
/// </summary>
[Description("要绑定的数据表达式格式")]
public string DataFormatString
{
get
{
return this.ViewState["DataFormatString"] as string;
}
set
{
this.ViewState["DataFormatString"] = value;
}
}
/// <summary>
/// return self;
/// </summary>
/// <returns></returns>
protected override DataControlField CreateField()
{
return this;
}
/// <summary>
/// 添加控件
/// </summary>
/// <param name="cell"></param>
/// <param name="cellType"></param>
/// <param name="rowState"></param>
/// <param name="rowIndex"></param>
public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
{
base.InitializeCell(cell, cellType, rowState, rowIndex);
if (cellType == DataControlCellType.DataCell)
{
var literal = new Literal();
if (string.IsNullOrEmpty(this.DataField))
{
SetLiteralHtml(literal, rowIndex.ToString());
}
else
{
literal.DataBinding += new EventHandler(literal_DataBinding);
}
cell.Controls.Add(literal);
}
}
void literal_DataBinding(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.DataField))
{
return;
}
var literal = sender as Literal;
if (literal == null)
{
return;
}
var cell = literal.Parent as TableCell;
if (cell == null)
{
return;
}
var container = literal.NamingContainer;
if (container == null)
{
return;
}
bool foundDataItem;
var dataItem = DataBinder.GetDataItem(container, out foundDataItem);
if (!foundDataItem)
{
return;
}
var dataValue = null as string;
if (this.DataField.Contains('.'))
{
dataValue = DataBinder.Eval(dataItem, this.DataField, this.DataFormatString);
}
else
{
dataValue = DataBinder.GetPropertyValue(dataItem, this.DataField, this.DataFormatString);
}
SetLiteralHtml(literal, dataValue);
}
private void SetLiteralHtml(Literal literal, string dataValue)
{
var groupName = this.RadioButtonGroupName;
if (string.IsNullOrEmpty(groupName))
{
groupName = literal.Parent.Parent.Parent.Parent.ID;
}
var cssClass = this.RadioButtonCssClass;
if (!string.IsNullOrEmpty(cssClass))
{
cssClass = string.Format("class=\"{0}\"", this.RadioButtonCssClass);
}
var selected = false;
var selectedValue = literal.Page.Request[groupName];
if (string.IsNullOrEmpty(selectedValue) == false)
{
if (string.Compare(selectedValue, dataValue, true) == 0)
{
selected = true;
}
}
var rbHtml = string.Format("<input type=\"radio\" name=\"{0}\" value=\"{1}\" {2} {3} />",
groupName,
dataValue,
cssClass,
selected ? "checked" : string.Empty);
literal.Text = rbHtml;
}
}
/// <summary>
/// 单选按钮列
/// </summary>
/// <remarks>
/// 如果没有设置GroupName,则使用GridView的ID作为GroupName
/// 如果没有设置DataField,则使用RowIndex作为Value
/// 允许设置DataFormatString格式化数据
/// </remarks>
[AspNetHostingPermission(SecurityAction.Demand,
Level = AspNetHostingPermissionLevel.Minimal)]
public class RadioButtonSelectField : DataControlField
{
/// <summary>
/// 单选按钮组名,默认去GridView的ClientID
/// </summary>
[Description("单选按钮组名,默认去GridView的ClientID")]
public string RadioButtonGroupName
{
get
{
return this.ViewState["RadioButtonGroupName"] as string;
}
set
{
this.ViewState["RadioButtonGroupName"] = value;
}
}
/// <summary>
/// 单选按钮的样式
/// </summary>
[Description("单选按钮的样式")]
public string RadioButtonCssClass
{
get
{
return this.ViewState["RadioButtonCssClass"] as string;
}
set
{
this.ViewState["RadioButtonCssClass"] = value;
}
}
/// <summary>
/// 要绑定的数据表达式
/// </summary>
[Description("要绑定的数据表达式")]
public string DataField
{
get
{
return this.ViewState["DataField"] as string;
}
set
{
this.ViewState["DataField"] = value;
}
}
/// <summary>
/// 要绑定的数据表达式格式
/// </summary>
[Description("要绑定的数据表达式格式")]
public string DataFormatString
{
get
{
return this.ViewState["DataFormatString"] as string;
}
set
{
this.ViewState["DataFormatString"] = value;
}
}
/// <summary>
/// return self;
/// </summary>
/// <returns></returns>
protected override DataControlField CreateField()
{
return this;
}
/// <summary>
/// 添加控件
/// </summary>
/// <param name="cell"></param>
/// <param name="cellType"></param>
/// <param name="rowState"></param>
/// <param name="rowIndex"></param>
public override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
{
base.InitializeCell(cell, cellType, rowState, rowIndex);
if (cellType == DataControlCellType.DataCell)
{
var literal = new Literal();
if (string.IsNullOrEmpty(this.DataField))
{
SetLiteralHtml(literal, rowIndex.ToString());
}
else
{
literal.DataBinding += new EventHandler(literal_DataBinding);
}
cell.Controls.Add(literal);
}
}
void literal_DataBinding(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.DataField))
{
return;
}
var literal = sender as Literal;
if (literal == null)
{
return;
}
var cell = literal.Parent as TableCell;
if (cell == null)
{
return;
}
var container = literal.NamingContainer;
if (container == null)
{
return;
}
bool foundDataItem;
var dataItem = DataBinder.GetDataItem(container, out foundDataItem);
if (!foundDataItem)
{
return;
}
var dataValue = null as string;
if (this.DataField.Contains('.'))
{
dataValue = DataBinder.Eval(dataItem, this.DataField, this.DataFormatString);
}
else
{
dataValue = DataBinder.GetPropertyValue(dataItem, this.DataField, this.DataFormatString);
}
SetLiteralHtml(literal, dataValue);
}
private void SetLiteralHtml(Literal literal, string dataValue)
{
var groupName = this.RadioButtonGroupName;
if (string.IsNullOrEmpty(groupName))
{
groupName = literal.Parent.Parent.Parent.Parent.ID;
}
var cssClass = this.RadioButtonCssClass;
if (!string.IsNullOrEmpty(cssClass))
{
cssClass = string.Format("class=\"{0}\"", this.RadioButtonCssClass);
}
var selected = false;
var selectedValue = literal.Page.Request[groupName];
if (string.IsNullOrEmpty(selectedValue) == false)
{
if (string.Compare(selectedValue, dataValue, true) == 0)
{
selected = true;
}
}
var rbHtml = string.Format("<input type=\"radio\" name=\"{0}\" value=\"{1}\" {2} {3} />",
groupName,
dataValue,
cssClass,
selected ? "checked" : string.Empty);
literal.Text = rbHtml;
}
}
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!
昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。
这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。
而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?
更新日志
2024年11月19日
2024年11月19日
- 潘盈.1993-旧情绵绵【名将】【WAV+CUE】
- 西野カナ《Loveit》24-96[FLAC]
- 群星2016-《环球词选周礼茂》[环球][WAV+CUE]
- XSProject-Бочкабасколбаср(TheBestOf)(LimitedEdition)[2024][WAV]
- 群星1997 《国语卖座舞曲大碟》引进版[WAV+CUE][1.1G]
- 汪峰 白金超精选专辑《笑着哭》[WAV+CUE][1G]
- 群星1998《舞池中98》香港首版[WAV+CUE]
- 林忆莲.2006-回忆莲莲3CD【滚石】【WAV+CUE】
- 品冠.2002-U-TURN180°转弯【滚石】【WAV+CUE】
- 温岚.2001-有点野【阿尔发】【WAV+CUE】
- 房东的猫2018-柔软[科文音像][WAV+CUE]
- 黄乙玲1993-台湾歌古早曲[台湾首版][WAV+CUE]
- 黑鸭子2008-男人女人[首版][WAV+CUE]
- 张佳佳 《FOLK SONG Ⅱ Impromptus OP.23(即兴曲7首)》[320K/MP3][98.71MB]
- 祖海 《我家在中国 (维也纳金色大厅独唱音乐会)》[320K/MP3][118.55MB]