本文整理汇总了C#中System.Web.UI.WebControls.BoundColumn类的典型用法代码示例。如果您正苦于以下问题:C# BoundColumn类的具体用法?C# BoundColumn怎么用?C# BoundColumn使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BoundColumn类属于System.Web.UI.WebControls命名空间,在下文中一共展示了BoundColumn类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
private void Page_Load(object sender, EventArgs e)
{
HtmlForm form1 = (HtmlForm) (HtmlForm)this.FindControl("Form1");
this.GHTTestBegin(form1);
base.GHTActiveSubTest = this.GHTSubTest1;
try
{
this.DataGrid1.DataSource = GHTTests.GHDataSources.DSDataTable();
BoundColumn column2 = new BoundColumn();
BoundColumn column3 = new BoundColumn();
BoundColumn column1 = new BoundColumn();
column2.DataField = "ID";
column3.DataField = "Name";
column1.DataField = "Company";
this.DataGrid1.Columns.Add(column2);
this.DataGrid1.Columns.Add(column3);
this.DataGrid1.Columns.Add(column1);
this.DataGrid1.DataBind();
}
catch (Exception exception2)
{
// ProjectData.SetProjectError(exception2);
Exception exception1 = exception2;
this.GHTSubTestUnexpectedExceptionCaught(exception1);
// ProjectData.ClearProjectError();
}
this.GHTTestEnd();
}
示例2: Page_Load
private void Page_Load(object sender, System.EventArgs e)
{
//Put user code to initialize the page here
System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
GHTTestBegin(frm);
GHTActiveSubTest = GHTSubTest1;
try
{
DataGrid1.DataSource = GHTTests.GHDataSources.DSDataTable();
System.Web.UI.WebControls.EditCommandColumn c_edt = new System.Web.UI.WebControls.EditCommandColumn();
System.Web.UI.WebControls.BoundColumn c_id = new System.Web.UI.WebControls.BoundColumn();
System.Web.UI.WebControls.ButtonColumn c_name = new System.Web.UI.WebControls.ButtonColumn();
System.Web.UI.WebControls.HyperLinkColumn c_company = new System.Web.UI.WebControls.HyperLinkColumn();
c_id.DataField = "ID";
c_name.DataTextField = "Name";
c_company.DataTextField = "Company";
DataGrid1.Columns.Add(c_edt);
DataGrid1.Columns.Add(c_id);
DataGrid1.Columns.Add(c_name);
DataGrid1.Columns.Add(c_company);
DataGrid1.DataBind();;
}
catch (Exception ex)
{
GHTSubTestUnexpectedExceptionCaught(ex);
}
GHTTestEnd();
}
示例3: AddRubricColumn
private void AddRubricColumn(string name, string bind)
{
BoundColumn col = new BoundColumn();
col.HeaderText = name;
col.DataField = bind;
dgAggregate.Columns.Add(col);
}
示例4: bind
public void bind()
{
SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["connectionString"]);
SqlDataAdapter da = new SqlDataAdapter("Select * from Customers",con);
DataTable dt = new DataTable("Customers");
da.Fill(dt);
if(DataGrid1.Attributes["SortOn"]!=null) dt.DefaultView.Sort=DataGrid1.Attributes["SortOn"];
BoundColumn col = new BoundColumn();
col.ReadOnly=true;
col.HeaderText="SL NO.";
DataGrid1.Columns.AddAt(0,col);
TemplateColumn col1 = new TemplateColumn();
col1.ItemTemplate =LoadTemplate("ItemTemplate.ascx");
col1.HeaderText="template - from ascx";
DataGrid1.Columns.Add(col1);
//E.Item.Cells[0].Text= E.Item.DataSetIndex + 1;
//http://www.dotnetbips.com/displayarticle.aspx?id=84
//http://www.dotnetbips.com/displayarticle.aspx?id=85
TemplateColumn col2 = new TemplateColumn();
col2.HeaderText = "template - from code";
col2.ItemTemplate = new CTemplateColumn("Customer_Name");
DataGrid1.Columns.Add(col2);
DataGrid1.DataSource=dt.DefaultView;
//next 2 lines to check if the pageindex is greater than noof pages when records are deleted from DB
double actualPageCount = Math.Ceiling(dt.Rows.Count / (double)DataGrid1.PageSize);
if(DataGrid1.CurrentPageIndex>=actualPageCount) DataGrid1.CurrentPageIndex =(int)actualPageCount - 1;
DataGrid1.DataBind();
}
示例5: CreateBoundColumn
protected BoundColumn CreateBoundColumn(DataColumn c, string[] col, int index)
{
BoundColumn column = new BoundColumn();
column.DataField = c.ColumnName;
column.HeaderText = col[index].ToString();
column.DataFormatString = setFormating(c);
return column;
}
示例6: GenerateCols
private void GenerateCols(DataTable dt,DataGrid dg)
{
foreach(DataColumn dc in dt.Columns)
{
BoundColumn bc = new BoundColumn();
bc.HeaderText=dc.ColumnName;
bc.DataField=dc.ColumnName;
dg.Columns.Add(bc);
}
}
示例7: bind
public void bind()
{
SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["connectionString"]);
string sql = "Select * from Customers";
string sortBy = DataGrid1.Attributes["SortOn"];
if(sortBy!=null && sortBy.Length>0)
{
sql += "order by " + sortBy;
}
SqlCommand comm = new SqlCommand(sql,con);
con.Open();
SqlDataReader reader = comm.ExecuteReader(CommandBehavior.CloseConnection);
BoundColumn col = new BoundColumn();
col.ReadOnly=true;
col.HeaderText="SL NO.";
DataGrid1.Columns.AddAt(0,col);
// TemplateColumn col1 = new TemplateColumn();
// col1.ItemTemplate =LoadTemplate("ItemTemplate.ascx");
// col1.HeaderText="template - from ascx";
// DataGrid1.Columns.Add(col1);
// //E.Item.Cells[0].Text= E.Item.DataSetIndex + 1;
// //http://www.dotnetbips.com/displayarticle.aspx?id=84
// //http://www.dotnetbips.com/displayarticle.aspx?id=85
// TemplateColumn col2 = new TemplateColumn();
// col2.HeaderText = "template - from code";
// col2.ItemTemplate = new CTemplateColumn("Customer_Name");
// DataGrid1.Columns.Add(col2);
DataGrid1.VirtualItemCount = DataGrid1.PageSize * 3 ;//3 pages
DataGrid1.DataSource=reader;
int loopMax = int.Parse(DataGrid1.Attributes["PageNo"]) * DataGrid1.PageSize;
for(int i=0;i<loopMax && reader.Read();i++);
//next 2 lines to check if the pageindex is greater than noof pages when records are deleted from DB
//double actualPageCount = Math.Ceiling(dt.Rows.Count / (double)DataGrid1.PageSize);
//if(DataGrid1.CurrentPageIndex>=actualPageCount) DataGrid1.CurrentPageIndex =(int)actualPageCount - 1;
DataGrid1.DataBind();
if(reader.IsClosed || !reader.Read())
{
ArrayList pagers = new ArrayList(2);
getPager(DataGrid1,pagers);
foreach(DataGridItem pager in pagers)
{
//item = <TR><TD><(<:prev)</TD><TD> (a space)</TD><TD>>(>:next)</TD></TR>
LinkButton nextLink = (LinkButton)pager.Controls[0]/*tr*/.Controls[2]/*3rd td*/;
nextLink.ForeColor=Color.Crimson;
//nextLink.Enabled = false;
//nextLink.Click = null;
//nextLink.Command = null;
nextLink.Attributes.Add("onclick","return false;");
}
}
reader.Close();
}
示例8: GetApprovalList
/// <summary>
/// 获得通过的查询
/// </summary>
/// <param name="dgList"></param>
/// <param name="Table_Name"></param>
/// <param name="CorGuid"></param>
/// <param name="DateFrom"></param>
/// <param name="DateTo"></param>
/// <param name="PageSize"></param>
/// <param name="CurrentPageIndex"></param>
/// <param name="TotalNum"></param>
/// <param name="Message"></param>
public void GetApprovalList(System.Web.UI.WebControls.DataGrid dgList, string Table_Name, string CorGuid, string DateFrom, string DateTo, int PageSize, int CurrentPageIndex, out int TotalNum, out string Message)
{
DataView dvList = new CawApprovalSetDB().Select(Table_Name);
if(dvList.Count<1)
{
Message="审批信息还没有配置,请先至审批配置页面进行审批信息配置";
TotalNum = 0;
return;
}
//添加隐藏列GUID
BoundColumn col =new BoundColumn();
col.DataField = "GUID";
col.Visible = false;
dgList.Columns.Add(col);
string col_En = "COMPANY_NAME," + dvList[0]["COLLIST"].ToString().Trim() + ",SUBMITDATE,DATASTATUS_NAME";
string col_Cn = "企业名称," + dvList[0]["COLLIST_CN"].ToString().Trim() + ",申请日期,审批状态";
string[] colList = col_En.Split(',');
string[] colList_Cn = col_Cn.Split(',');
//添加显示列
for (int i = 0; i < colList.Length; i++)
{
BoundColumn col1 = new BoundColumn();
col1.HeaderText = colList_Cn[i];
col1.DataField = colList[i];
col1.HeaderStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
col1.ItemStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
dgList.Columns.Add(col1);
}
string Where = " AND B.DATASTATUS='2'";
Where += CorGuid == "" ? "" : " AND A." + dvList[0]["QUERYFIELD"].ToString().Trim() + "='" + CorGuid + "'";
Where += (DateFrom != "" && DateTo == "") ? " AND B.SUBMITDATE >=TO_DATE('" + DateFrom + "','yyyy-mm-dd')" : "";
Where += (DateFrom == "" && DateTo != "") ? " AND B.SUBMITDATE <=TO_DATE('" + DateTo + "','yyyy-mm-dd')" : "";
Where += (DateFrom != "" && DateTo != "") ? " AND B.SUBMITDATE >=TO_DATE('" + DateFrom + "','yyyy-mm-dd') AND B.SUBMITDATE <=TO_DATE('" + DateTo + "','yyyy-mm-dd')" : "";
string strSql = " SELECT '' AS TMP,A." + dvList[0]["COLLIST"].ToString().Trim().Replace(",",",A.") + ",A." + dvList[0]["KEYFIELD"].ToString().Trim() + " AS GUID,B.DATASTATUS_NAME,TO_CHAR(B.SUBMITDATE,'yyyy-mm-dd') SUBMITDATE,C.NAME AS COMPANY_NAME FROM " + Table_Name + " A INNER JOIN CAW_DATESTATUS B ON A." + dvList[0]["KEYFIELD"].ToString().Trim() + "=B.KEYGUID INNER JOIN CAW_COMPANY C ON A." + dvList[0]["QUERYFIELD"].ToString().Trim() + "=C.GUID" + Where;
strSql = FrameCommon.GetPageSql(CawConnStr, out TotalNum, CurrentPageIndex, PageSize, strSql, "GUID", " ORDER BY SUBMITDATE DESC");
Database db = DatabaseFactory.CreateDatabase(CawConnStr);
DbCommand cmd = db.GetSqlStringCommand(strSql);
try
{
dgList.DataSource = db.ExecuteDataView(cmd);
dgList.DataBind();
Message = "";
}
catch(Exception err)
{
Message = "审批信息配置错误";
TotalNum = 0;
return;
}
}
示例9: addBoundColumnToGrid
/// <summary>
/// Agrega una nueva columna al DataGrid
/// </summary>
/// <param name="MyDataGrid">Objeto DataGrid a actualizar</param>
/// <param name="myDatatable">Objeto Datatable con los datos</param>
/// <param name="objBound_column">Objeto BoundColumn a agregar</param>
/// <remarks>
/// <list> Creado: Diciembre 10 de 2013 - Ing. David Alejandro Pineda Diaz </list>
/// </remarks>
public static void addBoundColumnToGrid(ref DataGrid MyDataGrid, DataTable myDatatable, BoundColumn objBound_column)
{
try
{
MyDataGrid.Columns.Add(objBound_column);
updateGrid(ref MyDataGrid, myDatatable);
}
catch (Exception ex)
{
throw ex;
}
}
示例10: GetColumn
private System.Web.UI.WebControls.BoundColumn GetColumn(string dataField, string headerText, System.Web.UI.WebControls.HorizontalAlign alignment)
{
System.Web.UI.WebControls.BoundColumn colBound = new System.Web.UI.WebControls.BoundColumn();
colBound.DataField = dataField;
colBound.HeaderText = headerText;
colBound.Initialize();
colBound.HeaderStyle.CssClass = "ektronTitlebar";
colBound.ItemStyle.Wrap = true;
colBound.ItemStyle.HorizontalAlign = alignment;
colBound.ItemStyle.CssClass = "history-list";
colBound.HeaderStyle.Height = Unit.Empty;
return colBound;
}
示例11: AddBoundColumn
/// <summary>
/// Adds a bound column to the datagrid with a format string for the
/// data field. This is used to create hyperlinks to say an email address.
/// </summary>
/// <param name="headerText">The header text.</param>
/// <param name="dataField">The data field.</param>
/// <param name="dataFormat">The data format.</param>
/// <param name="readOnly">if set to <c>true</c> [read only].</param>
public void AddBoundColumn(string headerText, string dataField, string dataFormat, bool readOnly)
{
BoundColumn column;
column = new BoundColumn();
column.HeaderText = String.Format("<strong>{0}</strong>", headerText);
column.DataField = dataField;
column.ReadOnly = readOnly;
column.HeaderStyle.CssClass = "ms-TPHeader";
column.ItemStyle.CssClass = "ms-alternating";
if (dataFormat != String.Empty)
column.DataFormatString = dataFormat;
this.Columns.Add(column);
}
示例12: Page_Load
private void Page_Load(object sender, System.EventArgs e)
{
//Put user code to initialize the page here
System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
GHTTestBegin(frm);
GHTActiveSubTest = GHTSubTest1;
try
{
DataGrid1.DataSource = GHTTests.GHDataSources.DSDataTable();;
System.Web.UI.WebControls.BoundColumn c_id = new System.Web.UI.WebControls.BoundColumn();
System.Web.UI.WebControls.BoundColumn c_name = new System.Web.UI.WebControls.BoundColumn();
System.Web.UI.WebControls.BoundColumn c_company = new System.Web.UI.WebControls.BoundColumn();
c_id.DataField = "ID";
c_name.DataField = "Name";
c_company.DataField = "Company";
c_id.DataFormatString = "";
c_name.DataFormatString = "slkdjflkfslkjf slkfjsl ks jlflks d";
c_company.DataFormatString = "{0:c2}";
DataGrid1.Columns.Add(c_id);
DataGrid1.Columns.Add(c_name);
DataGrid1.Columns.Add(c_company);
DataGrid1.DataBind();;
GHTSubTestAddResult(c_id.DataFormatString);
GHTSubTestAddResult(c_name.DataFormatString);
GHTSubTestAddResult(c_company.DataFormatString);
}
catch (Exception ex)
{
GHTSubTestUnexpectedExceptionCaught(ex);
}
GHTActiveSubTest = Ghtsubtest2;
try
{
DataGrid2.DataSource = GHTTests.GHDataSources.DSDataTable();
DataGrid2.DataBind();;
}
catch (Exception ex)
{
GHTSubTestUnexpectedExceptionCaught(ex);
}
GHTTestEnd();
}
示例13: populateDataGridWithSqlQueryResults
private void populateDataGridWithSqlQueryResults()
{
try
{
string sqlQueryToexecute = Server.HtmlDecode(txtSqlQueryToExecute.Text);
XmlNode[] sqlQueryResults = (XmlNode[])Global.objAccountManagement.WS_ExecuteSqlQuery("",sqlQueryToexecute);
if (sqlQueryResults[0].ChildNodes.Count >0)
{
//Create DataGrid Table Headers
DataTable dataTableWithSqlQueryResults = new DataTable();
for (int i=0; i < sqlQueryResults[0].ChildNodes.Count;i++)
{
XmlNode resultItem = sqlQueryResults[0].ChildNodes[i];
BoundColumn dynamicDataGridColumn = new BoundColumn();
dynamicDataGridColumn.DataField = i.ToString();
dynamicDataGridColumn.HeaderText = resultItem.InnerText;
dgQueryResult.Columns.Add(dynamicDataGridColumn);
dataTableWithSqlQueryResults.Columns.Add(i.ToString());
}
if (sqlQueryResults.Length>1)
{
//Populate DataGrid Table
for (int j=1; j<sqlQueryResults.Length;j++)
{
//DataRow dynamicDataRow = dataTableWithSqlQueryResults.NewRow();
object[] rowData = new object[sqlQueryResults[j].ChildNodes.Count];
for (int i=0; i < sqlQueryResults[j].ChildNodes.Count;i++)
{
XmlNode resultItem = sqlQueryResults[j].ChildNodes[i];
rowData[i] = Server.HtmlEncode(resultItem.InnerText);
}
dataTableWithSqlQueryResults.Rows.Add(rowData);
}
}
dgQueryResult.DataSource = dataTableWithSqlQueryResults;
dgQueryResult.DataBind();
}
}
catch (Exception Ex)
{
lblErrorMessage.Text = Ex.Message;
}
}
示例14: Display_ViewAllFont
private void Display_ViewAllFont()
{
TR_ViewAllFont.Visible = true;
FontData[] font_data_list;
font_data_list = m_refContApi.GetAllFonts();
if (!(font_data_list == null))
{
System.Web.UI.WebControls.BoundColumn colBound = new System.Web.UI.WebControls.BoundColumn();
colBound.DataField = "ID";
colBound.HeaderText = m_refMsg.GetMessage("generic Fontname");
ViewFontGrid.Columns.Add(colBound);
colBound = new System.Web.UI.WebControls.BoundColumn();
colBound.DataField = "TITLE";
colBound.HeaderText = m_refMsg.GetMessage("generic Font Face Sample");
ViewFontGrid.Columns.Add(colBound);
DataTable dt = new DataTable();
DataRow dr;
int i = 0;
dt.Columns.Add(new DataColumn("ID", typeof(string)));
dt.Columns.Add(new DataColumn("TITLE", typeof(string)));
for (i = 0; i <= font_data_list.Length - 1; i++)
{
dr = dt.NewRow();
dr[0] = "<a href=\"font.aspx?action=View&id=" + font_data_list[i].Id + "\" title=\'" + m_refMsg.GetMessage("click to view font msg") + " \"" + Strings.Replace(font_data_list[i].Face, "\'", "`", 1, -1, 0) + "\"\'>" + font_data_list[i].Face + "</a>";
dr[1] = "<font face=\"" + font_data_list[i].Face + "\">" + m_refMsg.GetMessage("sample font face style") + "</font>";
dt.Rows.Add(dr);
}
ViewFontGrid.BorderColor = System.Drawing.Color.White;
DataView dv = new DataView(dt);
ViewFontGrid.DataSource = dv;
ViewFontGrid.DataBind();
}
ViewFontsByGroupToolBar();
}
示例15: BoundColumnItem
public BoundColumnItem(BoundColumn runtimeColumn)
: base(runtimeColumn, 1)
{
}