📄 hyperlinkcolumn.cs
字号:
using System;
using System.ComponentModel;
namespace System.Web.UI.WebControls
{
/// <summary>
/// Summary description for HyperLinkColumn.
/// </summary>
public class HyperLinkColumn : DataGridColumn
{
private System.ComponentModel.PropertyDescriptor textFieldDesc;
private System.ComponentModel.PropertyDescriptor urlFieldDesc;
public HyperLinkColumn() : base()
{
}
protected virtual string FormatDataNavigateUrlValue(object dataUrlValue)
{
string local0;
string local1;
local0 = System.String.Empty;
if (dataUrlValue != null && dataUrlValue != System.DBNull.Value)
{
local1 = this.DataNavigateUrlFormatString;
if (local1.Length == 0)
local0 = dataUrlValue.ToString();
else
local0 = System.String.Format(local1, dataUrlValue);
}
return local0;
}
protected virtual string FormatDataTextValue(object dataTextValue)
{
string local0;
string local1;
local0 = System.String.Empty;
if (dataTextValue != null && dataTextValue != System.DBNull.Value)
{
local1 = this.DataTextFormatString;
if (local1.Length == 0)
local0 = dataTextValue.ToString();
else
local0 = System.String.Format(local1, dataTextValue);
}
return local0;
}
public virtual void Initialize()
{
this.Initialize();
this.textFieldDesc = null;
this.urlFieldDesc = null;
}
public virtual void InitializeCell(TableCell cell, int columnIndex, ListItemType itemType)
{
HyperLink local0;
this.InitializeCell(cell, columnIndex, itemType);
if (itemType != 0 && itemType != ListItemType.Footer)
{
local0 = new HyperLink();
local0.Text = this.Text;
local0.NavigateUrl = this.NavigateUrl;
local0.Target = this.Target;
if (this.DataNavigateUrlField.Length != 0 || this.DataTextField.Length != 0)
{
// local0.add_DataBinding(new EventHandler(this.OnDataBindColumn));
}
cell.Controls.Add(local0);
}
}
private void OnDataBindColumn(object sender, EventArgs e)
{
HyperLink local0;
DataGridItem local1;
object local2;
PropertyDescriptorCollection local3;
string local4;
object local5;
string local6;
object local7;
string local8;
local0 = (HyperLink) sender;
local1 = (DataGridItem) local0.NamingContainer;
local2 = local1.DataItem;
if (this.textFieldDesc == null && this.urlFieldDesc == null)
{
local3 = System.ComponentModel.TypeDescriptor.GetProperties(local2);
local4 = this.DataTextField;
if (local4.Length != 0)
{
this.textFieldDesc = local3.Find(local4, true);
if (this.textFieldDesc == null && !(this.DesignMode))
throw new HttpException(System.Web.HttpRuntime.FormatResourceString("Field_Not_Found", local4));
}
local4 = this.DataNavigateUrlField;
if (local4.Length != 0)
{
this.urlFieldDesc = local3.Find(local4, true);
if (this.urlFieldDesc == null && !(this.DesignMode))
throw new HttpException(System.Web.HttpRuntime.FormatResourceString("Field_Not_Found", local4));
}
}
if (this.textFieldDesc != null)
{
local5 = this.textFieldDesc.GetValue(local2);
local6 = this.FormatDataTextValue(local5);
local0.Text = local6;
}
else if (this.DesignMode && this.DataTextField.Length != 0)
local0.Text = System.Web.SR.GetString("Sample_Databound_Text");
if (this.urlFieldDesc != null)
{
local7 = this.urlFieldDesc.GetValue(local2);
local8 = this.FormatDataNavigateUrlValue(local7);
local0.NavigateUrl = local8;
return;
}
if (this.DesignMode && this.DataNavigateUrlField.Length != 0)
local0.NavigateUrl = "url";
}
public virtual string DataNavigateUrlField
{
get
{
object local0;
local0 = this.ViewState["DataNavigateUrlField"];
if (local0 != null)
return (String) local0;
return System.String.Empty;
}
set
{
this.ViewState["DataNavigateUrlField"]= value;
this.OnColumnChanged();
}
}
public virtual string DataNavigateUrlFormatString
{
get
{
object local0;
local0 = this.ViewState["DataNavigateUrlFormatString"];
if (local0 != null)
return (String) local0;
return System.String.Empty;
}
set
{
this.ViewState["DataNavigateUrlFormatString"]= value;
this.OnColumnChanged();
}
}
public virtual string DataTextField
{
get
{
object local0;
local0 = this.ViewState["DataTextField"];
if (local0 != null)
return (String) local0;
return System.String.Empty;
}
set
{
this.ViewState["DataTextField"]= value;
this.OnColumnChanged();
}
}
public virtual string DataTextFormatString
{
get
{
object local0;
local0 = this.ViewState["DataTextFormatString"];
if (local0 != null)
return (String) local0;
return System.String.Empty;
}
set
{
this.ViewState["DataTextFormatString"]= value;
this.OnColumnChanged();
}
}
public virtual string NavigateUrl
{
get
{
object local0;
local0 = this.ViewState["NavigateUrl"];
if (local0 != null)
return (String) local0;
return System.String.Empty;
}
set
{
this.ViewState["NavigateUrl"]= value;
this.OnColumnChanged();
}
}
public virtual string Target
{
get
{
object local0;
local0 = this.ViewState["Target"];
if (local0 != null)
return (String) local0;
return System.String.Empty;
}
set
{
this.ViewState["Target"]= value;
this.OnColumnChanged();
}
}
public virtual string Text
{
get
{
object local0;
local0 = this.ViewState["Text"];
if (local0 != null)
return (String) local0;
return System.String.Empty;
}
set
{
this.ViewState["Text"]= value;
this.OnColumnChanged();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -