GridView自定義分頁---派生類(5)
来源:互联网 发布:淘宝淘宝网首页 编辑:程序博客网 时间:2024/05/02 04:50
/// <summary>
/// 重新綁定所有資料,不做分頁
/// </summary>
private void DataBindForExcel()
{
SetDataSource(true);
TotalPage = -1;
this.DataBind();
}
/// <summary>
/// 重新綁定所有資料
/// </summary>
public void ReDataBind()
{
SetDataSource(false);
this.DataBind();
}
#region 清除gridview子元件
/// <summary>
/// 設定Cell的文字為元件的Text屬性
/// </summary>
private void RenderDataToText()
{
string[] arrIdx = ExportExcelClearControlIndex.Split(',');
foreach (GridViewRow row in this.Rows)
{
foreach (string idx in arrIdx)
{
TableCell cell = row.Cells[Convert.ToInt16(idx)];
if (cell.HasControls())
{
string cellText = "";
foreach (Control ctl in cell.Controls)
{
string value = "";
if (ctl.GetType().GetProperty("SelectedItem") != null)
{
value =
ctl.GetType().GetProperty("SelectedItem").GetValue(ctl, null).ToString();
}
else if (ctl.GetType().GetProperty("Text") != null)
{
value =
ctl.GetType().GetProperty("Text").GetValue(ctl, null).ToString();
}
if (value.Trim().Length > 0)
{
cellText += TrimHref(value.Trim()) + " ";
}
}
cell.Text = cellText;
}
else
{
cell.Text = TrimHref(cell.Text);
}
}
}
}
/// <summary>
/// 移除連結字申
/// </summary>
/// <param name="value">欄位文字</param>
/// <returns>已移除連結字申的欄位文字</returns>
private string TrimHref(string value)
{
if (value.ToLower().IndexOf("<a") > -1 && value.ToLower().IndexOf("</a>") > -1)
{
string pattent = @"<a(.*?)</a>";
List<string> linkInfos = new List<string>();
MatchCollection matches = Regex.Matches(value, pattent, RegexOptions.IgnoreCase);
foreach (Match match in matches)
{
linkInfos.Add(Regex.Replace(
Regex.Replace(match.Value, "<a(.*?)>", "", RegexOptions.IgnoreCase),
"</a>", "", RegexOptions.IgnoreCase));
}
return String.Join(Environment.NewLine, linkInfos.ToArray());
}
return value;
}
#endregion
}
}
- GridView自定義分頁---派生類(5)
- GridView自定義分頁---派生類(1)
- GridView自定義分頁---派生類(2)
- GridView自定義分頁---派生類(3)
- GridView自定義分頁---派生類(4a) .
- GridView自定義分頁---派生類(4b) .
- gridview 自定義分頁 DEMO
- QNetWorkReply 派生自 QIODevice类
- GridView中資料內容自動換行
- GridView 加入自動編號欄位
- 自绘GridView控件
- GridView 自带分页
- GridView自带排序
- GridView自增一列
- 派生自 java.util.Observable 类
- GridView插入自定义行
- gridview自带分页《续》
- Android自绘GridView控件
- cocos2dx-2.1.5 ddz-游戏开发之旅(一) 利用cocos2dx显示中文
- 防痴呆设计
- 织梦DEDECMS search.php注入漏洞EXP[通杀]
- PROC基础知识之指示变量变量
- Eclipse快捷键 10个最有用的快捷键
- GridView自定義分頁---派生類(5)
- android或java用DES加密解密文件
- HTTP could not register URL http://+:8000/ServiceModelSamples/service/. Your
- android -- 蓝牙 bluetooth (五)接电话与听音乐
- 【分享】带有转发和情感标签的微博数据
- App开源项目收集和汇总:App Store地址和源代码(二)
- pro*c动态SQL技术
- PackageManagerService概述
- Linux下错误:文本文件每一行最后多了 ^M