
请教一下如何用c#,实现提取数据库中的sum值 20
下面是我的代码protectedvoidGridView1_RowDataBound(objectsender,GridViewRowEventArgse){DataCo...
下面是我的代码
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
DataControlRowType itemType = e.Row.RowType;
if (e.Row.RowType == DataControlRowType.Header || e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onmouseover"] = "javascript:setMouseOverColor(this);";
e.Row.Attributes["onmouseout"] = "javascript:setMouseOutColor(this);";
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lzn = (Label)e.Row.FindControl("lzid");
Label lzl = (Label)e.Row.FindControl("lznum");
string SQL_GetSum_lz = "select Sum(JcXiangMu) from qp_hr_YGJC where BuMenId in (" + Session["BmQx"] + ") and BuMenId='" + lzn.Text + "' and (JcShijian between '" + StartTime.Text + "'and '" + EndTime.Text + "' or convert(char(10),cast(JcShijian as datetime),120)=convert(char(10),cast('" + StartTime.Text + "' as datetime),120) or convert(char(10),cast(JcShijian as datetime),120)=convert(char(10),cast('" + EndTime.Text + "' as datetime),120) ) ";
string count_lz = "" + List.GetSum(SQL_GetSum_lz) + "";
lzl.Text = null;
lzl.Text = "<a href=\"javascript:void(0)\" onclick=\"openfrom1('StartTime=" + StartTime.Text + "&EndTime=" + EndTime.Text + "&BuMenId=" + lzn.Text + "')\">" + count_lz + "</a>";
//总额
}
} 展开
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
DataControlRowType itemType = e.Row.RowType;
if (e.Row.RowType == DataControlRowType.Header || e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onmouseover"] = "javascript:setMouseOverColor(this);";
e.Row.Attributes["onmouseout"] = "javascript:setMouseOutColor(this);";
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lzn = (Label)e.Row.FindControl("lzid");
Label lzl = (Label)e.Row.FindControl("lznum");
string SQL_GetSum_lz = "select Sum(JcXiangMu) from qp_hr_YGJC where BuMenId in (" + Session["BmQx"] + ") and BuMenId='" + lzn.Text + "' and (JcShijian between '" + StartTime.Text + "'and '" + EndTime.Text + "' or convert(char(10),cast(JcShijian as datetime),120)=convert(char(10),cast('" + StartTime.Text + "' as datetime),120) or convert(char(10),cast(JcShijian as datetime),120)=convert(char(10),cast('" + EndTime.Text + "' as datetime),120) ) ";
string count_lz = "" + List.GetSum(SQL_GetSum_lz) + "";
lzl.Text = null;
lzl.Text = "<a href=\"javascript:void(0)\" onclick=\"openfrom1('StartTime=" + StartTime.Text + "&EndTime=" + EndTime.Text + "&BuMenId=" + lzn.Text + "')\">" + count_lz + "</a>";
//总额
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询