defalt.aspx 页面最上放引入空间
<%@ Import Namespace="System.Data"%>
这里是想要循环生成列的值,这里的chen为全局变量,在代码编写页面上有
<% foreach (DataRow dh in chen.Rows)
{
%>
<tr>
<td style="width: 196px; height: 9px;"><span style="width: 11%">学生课程名称:</span></td>
<td style="width: 213px; height: 9px;"><%=dh["f_name"].ToString() %>
</td>
<td style="width: 203px; height: 9px;"><span style="width: 11%">学生专业总评成绩:</span></td>
<td style="width: 304px; height: 9px;"><%=getall(dh["f_k_lessonid"].ToString(), dh["f_FlowID"].ToString())%>
</td>
<td style="width: 64px; height: 9px;">
是否及格:</td>
<td style="height: 9px; width: 89px;">
<%=getok(dh["f_k_lessonid"].ToString(), dh["f_FlowID"].ToString())%>
</td>
</tr>
<%
}
%>
defalt.aspx.cs页面
1.在页面上绑定的字段根据自己的需求来写。
//System.mySQLConnection.SqlConnections.GetDataTable(sql, "sdaas");//这个类见我的空间里面有详细的写法
public DataTable chen;//申明全局变量datatable chen
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string o_flowid = Request["f_StudentID"].ToString().Trim();
string s_name = Request["s_name"].ToString().Trim();
this.Text1.Value = o_flowid.ToString();
this.tbxteachername.Value = s_name;
this.aaa.Value = o_flowid.ToString().Trim();
string sql = "select d.f_k_lessonid,d.f_name,a.f_FlowID from grade_students as a join t_major_2 as b on a.f_k_majorID=b.f_k_majorid join t_major_gx as c on b.f_k_majorid=c.f_k_majorid left join t_lesson_ke as d on c.f_k_lessonid=d.f_k_lessonid where a.f_FlowID='" + o_flowid + "'";
chen = new DataTable();
chen=System.mySQLConnection.SqlConnections.GetDataTable(sql, "sdaas");
}
public string getall(string id,string userid)
{
string massageinfo = "";
string sqla = "select defen from chengjidankeinfo where kemu='"+ id +"' and o_flowid='"+ userid +"'";
DataTable ddd = System.mySQLConnection.SqlConnections.GetDataTable(sqla, "das");
if (ddd != null && ddd.Rows.Count > 0)
{
massageinfo = ddd.Rows[0]["defen"].ToString().Trim()+"分";
}
else
{
massageinfo = "<font color='red'>成绩未录入</font>";
}
return massageinfo;
}
public string getok(string id, string userid)
{
string massageinfo = "";
string sqla = "select defen from chengjidankeinfo where kemu='" + id + "' and o_flowid='" + userid + "'";
DataTable ddd = System.mySQLConnection.SqlConnections.GetDataTable(sqla, "das");
if (ddd != null && ddd.Rows.Count > 0)
{
massageinfo = ddd.Rows[0]["defen"].ToString().Trim();
if ( Convert.ToDouble(massageinfo) >= 60)
{
massageinfo = "该科课程及格";
}
else
{
massageinfo = "<font color='red'>该科课程不及格</font>";
}
}
else
{
massageinfo = "<font color='red'>成绩未录入</font>";
}
return massageinfo;
}