获取datagrid列数,行数和单元格的值
14 个解决方案
#1
好像在按钮里先得获得datagrid
#2
datagrid列数,行数应该是datatable的列数,行数?!
单元格操作可以查看
http://dev.csdn.net/article/81/81195.shtm
单元格操作可以查看
http://dev.csdn.net/article/81/81195.shtm
#3
string bh = ((Label)this.GridView1.Rows[e.RowIndex].Cells[0].FindControl("lbl1")).Text;
例子自己看看
例子自己看看
#4
呵呵,datatable的列数,行数我会
我现在想把gridview,datagrid的数据写入excel
我想在按钮事件中先获取它们的行数和列数
我现在想把gridview,datagrid的数据写入excel
我想在按钮事件中先获取它们的行数和列数
#5
gridview datagrid是动态绑定的
#6
你取控件后边绑定的源的列或行就行.比如你后边绑的是个DataTable,那你就取它的
#7
GridView1.Rows.Count
GridView1.Columns.Count
我没测..
GridView1.Columns.Count
我没测..
#8
int c = GridView1.Columns.Count; // 列数
int r = GridView1.Rows.Count; // 行数
int cells = c * r; // 单元格数当然是 行 * 列 la!
int r = GridView1.Rows.Count; // 行数
int cells = c * r; // 单元格数当然是 行 * 列 la!
#9
GridView1.Columns.Count()我取到的值一直都是零
#10
GridView单元格的的值怎么获取,比如第一行第一列
#11
datatable的列数,行数我会
我现在想把gridview,datagrid的数据写入excel
-------------------------
楼主是想知道这个答案吧!
int columes = GridView1.Columns.Count; // 列数
int row = GridView1.Rows.Count; // 行数
我现在想把gridview,datagrid的数据写入excel
-------------------------
楼主是想知道这个答案吧!
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindData();
}
}
private void BindData()
{
string query = "SELECT * FROM customers";
SqlConnection myConnection = new SqlConnection(ConnectionString);
SqlDataAdapter ad = new SqlDataAdapter(query, myConnection);
DataSet ds = new DataSet();
ad.Fill(ds, "customers");
GridView1.DataSource = ds;
GridView1.DataBind();
}
public override void VerifyRenderingInServerForm(Control control)
{
// Confirms that an HtmlForm control is rendered for
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Clear();
Response.AddHeader("content-disposition","attachment;filename=FileName.xls");
Response.Charset = "gb2312";
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite =new HtmlTextWriter(stringWrite);
GridView1.AllowPaging = false;
BindData();
GridView1.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
GridView1.AllowPaging = true;
BindData();
}
protected void paging(object sender,GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
BindData();
}
int columes = GridView1.Columns.Count; // 列数
int row = GridView1.Rows.Count; // 行数
#12
GridView1.Rows.Count
GridView1.Columns.Count
this.GridView1.Rows[e.RowIndex].Cells[0].FindControl("lbl1")
GridView1.Columns.Count
this.GridView1.Rows[e.RowIndex].Cells[0].FindControl("lbl1")
#13
qq22345111 的这种方法我已经实现了,这个方法在导入word后需要另存为,格式不好控制
我想改成word.application 和excel.application编程
我想改成word.application 和excel.application编程
#14
gridview表格头怎么读取
#1
好像在按钮里先得获得datagrid
#2
datagrid列数,行数应该是datatable的列数,行数?!
单元格操作可以查看
http://dev.csdn.net/article/81/81195.shtm
单元格操作可以查看
http://dev.csdn.net/article/81/81195.shtm
#3
string bh = ((Label)this.GridView1.Rows[e.RowIndex].Cells[0].FindControl("lbl1")).Text;
例子自己看看
例子自己看看
#4
呵呵,datatable的列数,行数我会
我现在想把gridview,datagrid的数据写入excel
我想在按钮事件中先获取它们的行数和列数
我现在想把gridview,datagrid的数据写入excel
我想在按钮事件中先获取它们的行数和列数
#5
gridview datagrid是动态绑定的
#6
你取控件后边绑定的源的列或行就行.比如你后边绑的是个DataTable,那你就取它的
#7
GridView1.Rows.Count
GridView1.Columns.Count
我没测..
GridView1.Columns.Count
我没测..
#8
int c = GridView1.Columns.Count; // 列数
int r = GridView1.Rows.Count; // 行数
int cells = c * r; // 单元格数当然是 行 * 列 la!
int r = GridView1.Rows.Count; // 行数
int cells = c * r; // 单元格数当然是 行 * 列 la!
#9
GridView1.Columns.Count()我取到的值一直都是零
#10
GridView单元格的的值怎么获取,比如第一行第一列
#11
datatable的列数,行数我会
我现在想把gridview,datagrid的数据写入excel
-------------------------
楼主是想知道这个答案吧!
int columes = GridView1.Columns.Count; // 列数
int row = GridView1.Rows.Count; // 行数
我现在想把gridview,datagrid的数据写入excel
-------------------------
楼主是想知道这个答案吧!
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindData();
}
}
private void BindData()
{
string query = "SELECT * FROM customers";
SqlConnection myConnection = new SqlConnection(ConnectionString);
SqlDataAdapter ad = new SqlDataAdapter(query, myConnection);
DataSet ds = new DataSet();
ad.Fill(ds, "customers");
GridView1.DataSource = ds;
GridView1.DataBind();
}
public override void VerifyRenderingInServerForm(Control control)
{
// Confirms that an HtmlForm control is rendered for
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Clear();
Response.AddHeader("content-disposition","attachment;filename=FileName.xls");
Response.Charset = "gb2312";
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite =new HtmlTextWriter(stringWrite);
GridView1.AllowPaging = false;
BindData();
GridView1.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
GridView1.AllowPaging = true;
BindData();
}
protected void paging(object sender,GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
BindData();
}
int columes = GridView1.Columns.Count; // 列数
int row = GridView1.Rows.Count; // 行数
#12
GridView1.Rows.Count
GridView1.Columns.Count
this.GridView1.Rows[e.RowIndex].Cells[0].FindControl("lbl1")
GridView1.Columns.Count
this.GridView1.Rows[e.RowIndex].Cells[0].FindControl("lbl1")
#13
qq22345111 的这种方法我已经实现了,这个方法在导入word后需要另存为,格式不好控制
我想改成word.application 和excel.application编程
我想改成word.application 和excel.application编程
#14
gridview表格头怎么读取