三层结构: 简单问题,在线立马结帐
三层结构:
oalc1.cs下的代码:
public DataSet oanb(String jsz) // 需要处理的文件
{
SqlConnection myConnection = new SqlConnection(
ConfigurationManager.ConnectionStrings[ "OAxitongConnectionString "].ConnectionString);
string cmdText = "select *from fasong1 where jsz= ' " + jsz + " ' order by sj desc ";
SqlDataAdapter sda = new SqlDataAdapter(cmdText, myConnection);
DataSet ds = new DataSet();
try
{
myConnection.Open();
sda.Fill(ds);
}
catch (SqlException ex)
{
throw new Exception(ex.Message, ex);
}
finally
{
myConnection.Close();
}
return ds;
}
index3.aspx.cs下的代码:
private void BindUserData(string yhm)
{
///获取用户数据
///
oalc1 user = new oalc1();
DataSet rr = user.oazb(yhm);
///设置GridView的数据源,并绑定数据
GridView1.DataSource = rr;
GridView1.DataKeyNames = new string[] { "bm " };
GridView1.DataBind();
if(e.item.cell[1].text == "1 ")
{
Label1.Text = "紧急 ";
}
else
{
Label1.Text = "一般 ";
}
///关闭数据读取器
}
index.aspx下的代码:
<asp:TemplateField HeaderText= "状态 ">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "jinji ") %>
<asp:Label ID= "Label1 " runat= "server " Text= " "> </asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign= "Center " VerticalAlign= "Middle " />
<HeaderStyle HorizontalAlign= "Center " VerticalAlign= "Middle " Width= "10% " />
</asp:TemplateField>
要求,当 "jinji " 为 2 时,Label.text=“一般”,为1时,Lable.text= "紧急 "
[解决办法]
或者
<asp:Label ID= "Label1 " runat= "server " Text= " "> </asp:Label>
=============================================================
<asp:Label ID= "Label1 " runat= "server " Text= ' <%#Eval( "你要判断的字段 ").ToString() == "1 " ? "紧急 " : "一般 " %> '> </asp:Label>
[解决办法]
或者,连 Label 都可以不用,直接
》》》
<asp:TemplateField HeaderText= "状态 ">
<ItemTemplate>
<%# Eval( "jinji ").ToString() == "1 " ? "紧急 " : "一般 " %>
</ItemTemplate>