下面求的是gridview中第5列的值,并在lable1中显示
protected void Page_Load(object sender, EventArgs e)
    {
        int b=0;
        DataSet1TableAdapters.fri dtdf = new DataSet1TableAdapters.friTableAdapter();
        DataSet1.friDataTable dtbl = new DataSet1.friDataTable();
        dtdf.Fill(dtbl);
        GridView1.DataSource=dtbl;
        GridView1.DataBind();
        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            int a=Convert.ToInt32( GridView1.Rows[i].Cells[4].Text);
            b = b + a;
        }
        Label1.Text = Convert.ToString(b);

    }

或者直接用sql语句写:select sum (lie) from biao

表的外连接查询
select a.userId,a.det,b.title,summary from biao_1 a inner join biao_2 b on a.id=b.id
当所查字段两个表中都有时,需要表明属于哪个表,如det字段在biao_1和biao_2中都有,则写a.det

查询表的行数select count(*) from biao

posted on 2013-08-28 17:16  御不凡  阅读(270)  评论(0编辑  收藏  举报