中国法律网
法律通行证: 用户名: 密码:  注册
律师加盟热线:400-8919-913   律信通 律信通  
律师
公众 咨询 贴吧
律信通 案件委托
频道 房产 婚姻 交通事故 保险 建设工程 劳动
留学
公司 合同 刑事辩护 医疗 知识产权 工商
新闻 宽频 文书 常识 案例
法规 专题 杂志 百科 论文
查找全国各地律师: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 点击各城市名拼音首字母查找律师 公众找律师,信赖律信通!律师做宣传,首选律信通!
公检法司
频道直达: 法界新闻 | 公安 | 检察 | 法院 | 司法 | 工商 | 税务 | 质检 | 聚焦国土 | 矿山与安全
公检法司
明星资讯明星新闻
当前位置: 主页 > 娱乐资讯 > 明星新闻 >

GridView操作(7) EventArgs e)

时间:2014-02-02 19:13来源:诗意地忧伤 作者:闲的无聊 中国法律网

   GridView1.DataSource = CreateDataSource();

GridView1.DataBind();

protected void Button1_Click(object sender, EventArgs e)

return myds;

myda.Fill(myds);

DataSet myds = new DataSet();

OleDbDataAdapter myda = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", strCon);

OleDbConnection olecon = new OleDbConnection(strCon);

strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("excel.xls") + "; Extended Properties=Excel 8.0;";

string strCon;

private DataSet CreateDataSource()

读取Excel数据的代码:这个很简单的

<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="导出" />

</asp:GridView>

<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />

<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" Css DataGridFixedHeader"/>

<SelectedRowStyle BackColor="#" Font-Bold="True" ForeColor="White" />

<RowStyle ForeColor="#000066" />

</Columns>

<asp:BoundField DataField="起薪" HeaderText="起薪" />

<asp:BoundField DataField="邮政编码" HeaderText="邮政编码" />

<asp:BoundField DataField="家庭住址" HeaderText="家庭住址" />

<asp:BoundField DataField="出生日期" HeaderText="邮政编码" />

<asp:BoundField DataField="姓名" HeaderText="姓名" />

<asp:BoundField DataField="身份证号码" HeaderText="编号" ReadOnly="True" />

<Columns>

<FooterStyle BackColor="White" ForeColor="#000066" />

BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" Font-Size="12px" >

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="3"

public override void VerifyRenderingInServerForm(Control control)

Response.End();

Response.Write(tw.ToString());

GridView1.RenderControl(hw);

HtmlTextWriter hw = new HtmlTextWriter(tw);

StringWriter tw = new StringWriter();

this.EnableViewState = false;

Response.ContentType = FileType;

Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());

Response.ContentEncoding = System.Text.Encoding.UTF7;

Response.Charset = "GB2312";

private void Export(string FileType, string FileName)

Export("application/ms-excel", "学生成绩报表.xls");

protected void Button1_Click(object sender, EventArgs e)

sqlcon.Close();

GridView1.DataBind();

GridView1.DataKeyNames = new string[] { "身份证号码" };

GridView1.DataSource = myds;

myda.Fill(myds, "飞狐工作室");

sqlcon.Open();

DataSet myds = new DataSet();

SqlDataAdapter myda = new SqlDataAdapter(sqlstr, sqlcon);

sqlcon = new SqlConnection(strCon);

string sqlstr = "select top 5 * from 飞狐工作室";

public void bind()

bind();

if (!IsPostBack)

protected void Page_Load(object sender, EventArgs e)

string strCon = "Data Source=(local);Database=北风贸易;Uid=sa;Pwd=sa";

SqlCommand sqlcom;

SqlConnection sqlcon;

public partial class Default7 : System.Web.UI.Page

using System.Text;

using System.IO;

using System.Drawing;

using System.Data.SqlClient;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.WebControls;

using System.Web.UI;

using System.Web.Security;

using System.Web;

using System.Configuration;

using System.Data;

using System;

后台代码:其实GridView操作(7)。

还有由于是文件操作所以要引入名称空间IO和Text

public override void VerifyRenderingInServerForm(Control control)

//如果没有下面方法会报错类型“GridView”的控件“GridView1”必须放在具有 runat=server 的窗体标记内

Response.End();

Response.Write(tw.ToString());

GridView1.RenderControl(hw);

HtmlTextWriter hw = new HtmlTextWriter(tw);

StringWriter tw = new StringWriter();

this.EnableViewState = false;

Response.ContentType = FileType;

Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());

Response.ContentEncoding = System.Text.Encoding.UTF7;

Response.Charset = "GB2312";

private void Export(string FileType, string FileName)

Export("application/ms-excel", "学生成绩报表.xls");

protected void Button1_Click(object sender, EventArgs e)

页面增加一个按钮,对比一下e)。学习

风雷动演员表GridView操作(7) EventArgs e)

否则默认表头为隐藏的!

解决方案:

效果图:听说EventArgs。

18.GridView数据导入Excel/Excel数据读入GridView

</asp:GridView>

<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />

<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" Css DataGridFixedHeader"/>

<SelectedRowStyle BackColor="#" Font-Bold="True" ForeColor="White" />

<RowStyle ForeColor="#000066" />

</Columns>

<asp:BoundField DataField="起薪" HeaderText="起薪" />

<asp:BoundField DataField="邮政编码" HeaderText="邮政编码" />

<asp:BoundField DataField="家庭住址" HeaderText="家庭住址" />

<asp:BoundField DataField="出生日期" HeaderText="邮政编码" />

<asp:BoundField DataField="姓名" HeaderText="姓名" />

<asp:BoundField DataField="身份证号码" HeaderText="编号" ReadOnly="True" />

<asp:CommandField HeaderText="编辑" ShowEditButton="True" />

<Columns>

<FooterStyle BackColor="White" ForeColor="#000066" />

OnRowUpdating="GridView1_RowUpdating" OnRowCancelingEdit="GridView1_RowCancelingEdit" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" Font-Size="12px" OnRowDataBound="GridView1_RowDataBound" ShowFooter="True" >

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="3" OnRowEditing="GridView1_RowEditing"

前台:唯一的花头就是设置ShowFooter="True",e)。你要根据具体情况对待可能你要处理的是int

e.Row.Cells[4].Text = ((int)(sum / GridView1.Rows.Count)).ToString();

e.Row.Cells[3].Text = "平均薪水为:";

e.Row.Cells[6].Text = sum.ToString();

e.Row.Cells[5].Text = "总薪水为:gridview。";

else if (e.Row.RowType == DataControlRowType.Footer)

sum += Convert.ToDouble(e.Row.Cells[6].Text);

if (e.Row.RowIndex >= 0)

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)

private double sum = 0;//取指定列的数据和

sqlcon.Close();

GridView1.DataBind();

GridView1.DataKeyNames = new string[] { "身份证号码" };

GridView1.DataSource = myds;

myda.Fill(myds, "飞狐工作室");

sqlcon.Open();

DataSet myds = new DataSet();

SqlDataAdapter myda = new SqlDataAdapter(sqlstr, sqlcon);

sqlcon = new SqlConnection(strCon);

string sqlstr = "select top 5 * from 飞狐工作室";

public void bind()

bind();

GridView1.EditIndex = -1;

protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)

bind();

GridView1.EditIndex = -1;

sqlcon.Close();

sqlcom.ExecuteNonQuery();

sqlcon.Open();

sqlcom = new SqlCommand(sqlstr, sqlcon);

+ GridView1.DataKeys[e.RowIndex].Value.ToString() + "'";

+ ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString().Trim() + "' where 身份证号码='"

+ ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim() + "',家庭住址='"

string sqlstr = "update 飞狐工作室 set 姓名='"

sqlcon = new SqlConnection(strCon);

protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)

bind();

GridView1.EditIndex = e.NewEditIndex;

protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)

bind();

if (!IsPostBack)

protected void Page_Load(object sender, EventArgs e)

string strCon = "Data Source=(local);Database=北风贸易;Uid=sa;Pwd=sa";

SqlCommand sqlcom;

SqlConnection sqlcon;

public partial class Default7 : System.Web.UI.Page

using System.Drawing;

using System.Data.SqlClient;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.WebControls;

using System.Web.UI;

using System.Web.Security;

using System.Web;

using System.Configuration;

using System.Data;

using System;

后台全部代码:操作。

李敏镐初次见面就绑架金喜善?韩剧《信义》引发好奇心即将在GridView操作(7) EventArgs e)

e.Row.Cells[4].Text = ((int)(sum / GridView1.Rows.Count)).ToString();

e.Row.Cells[3].Text = "平均薪水为:";

e.Row.Cells[6].Text = sum.ToString();

e.Row.Cells[5].Text = "总薪水为:听听eventargs。";

else if (e.Row.RowType == DataControlRowType.Footer)

sum += Convert.ToDouble(e.Row.Cells[6].Text);

if (e.Row.RowIndex >= 0)

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)

private double sum = 0;//取指定列的数据和, 解决方案:看着GridView操作(7)。

效果图:听听e。

17.GridView加入自动求和求平均值小计


EventArgs
(责任编辑:admin)
------分隔线----------------------------
免费法律咨询 在线提交,三十分钟内百分百回复!
中国法律网 版权所有 邮箱:service@5Law.cn 建议使用:1024x768分辨率,16位以上颜色 | 京ICP备2023040428号-1联系我们 有事点这里    [切换城市▲] 公司法
400-8919-913 工作日:9:00-18:00
周 六:9:00-12:00

法律咨询5分钟内回复
请用微信扫描二维码
关闭

关注网站CEO微信,与CEO对话