App_Code/DataControlHelper.cs
(完整代码) 1KBusing System.Data.Common;
using System.Web.UI.WebControls;
namespace Maticsoft.Utility
{
public static class DataControlHelper
{
/// <summary>
///
/// </summary>
/// <param name="wc">要绑定的控件</param>
/// <param name="dataSource">用于绑定的数据源</param>
public static void Bind(WebControl wc, object dataSource)
{
if (wc is GridView)
{
GridView gv = wc as GridView;
gv.DataSource = dataSource;
gv.DataBind();
}
if (wc is DataList)
{
DataList dl = wc as DataList;
dl.DataSource = dataSource;
dl.DataBind();
}
if (wc is ListControl)
{
ListControl lc = wc as ListControl;
//lc.Items.Clear();
lc.DataSource = dataSource;
lc.DataBind();
if (dataSource is DbDataReader)
{
DbDataReader dr = dataSource as DbDataReader;
dr.Close();
}
}
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。