DataGrid中多栏显示为一栏/webForm
来源:互联网 发布:宅男看片软件 编辑:程序博客网 时间:2024/05/03 06:00
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace WebApplication4
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
SqlConnection sqlConn = new SqlConnection("server =127.0.0.1; database = pubs; uid=sa; pwd=");
SqlDataAdapter sqlAda = new SqlDataAdapter("select * from authors",sqlConn);
// SqlDataAdapter sqlAda = new SqlDataAdapter("select au_id, au_lname + au_fname as name, phone, address, city, state from authors",sqlConn);
DataSet dsData = new DataSet("ds1");
sqlAda.Fill(dsData);
DataGrid1.DataSource = dsData;
DataGrid1.DataBind();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.DataGrid1.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.DataGrid1_ItemDataBound);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemIndex != -1)
// if(e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
//e.Item.Cells[3].Text =((TextBox)(e.Item.Cells[1].Controls[0])).Text.ToString()+ ((TextBox)(e.Item.Cells[2].Controls[0])).Text.ToString();
e.Item.Cells[3].Text = e.Item.Cells[1].Text.ToString() + e.Item.Cells[2].Text.ToString();
}
if(e.Item.ItemIndex == 5)
{
e.Item.Cells[0].Text = "我的定义";
}
}
}
}
- DataGrid中多栏显示为一栏/webForm
- WebForm Datagrid Advanced Skill
- apk去掉顶上一栏,全屏显示
- asp.net webform 中将前台显示出来的html标签解释为排版格式
- 浅谈WebForm中DataGrid的ItemDataBound事件
- webform中DataGrid的经典文章
- 浅谈WebForm中DataGrid的ItemDataBound事件
- WebForm中DataGrid的经典文章
- 浅谈WebForm中DataGrid的ItemDataBound事件
- 浅谈WebForm中DataGrid的ItemDataBound事件
- C#显示PDF文件(webform)
- cxGrid增加一栏显示checkBox的设置方法
- cxGrid增加一栏显示checkBox的设置方法
- cxGrid增加一栏显示checkBox的设置方法
- DataGrid 把0,1,2 显示为 “未完成”“通过”“不通过”
- [EasyUI] Datagrid中文列头显示为乱码
- datagrid返回记录为0时显示“没有记录”
- DataGrid中列值为显示为空但后台实际取值不为空
- (二)初步了解
- 怎样判断一个坐标是否在已知三角形内?
- 交叉编译介绍
- 人脸确认系统demo开发笔录
- === 常 识 集 锦 ===
- DataGrid中多栏显示为一栏/webForm
- Spring 框架简介
- 夏天晚上睡觉点蚊香对身体有害?+几招防蚊、驱蚊办法
- 生成QQ菜单代码
- 2006 互联网的又一个春天 成都网络主题峰会成都理工大学现场纪实
- 征集国内操作系统项目列表
- 当Hibernate遇上Spring
- google hacking的实现以及应用
- 配色方案