在ASP中比较容易的实现的问题,在ASP.NET中还真不知道怎么写代码了,各位大哥帮帮忙啊!
比如我的商品有两个价格,一个是普通价格,一个是特殊价格.现在我想在商品有特殊价格时显示并且普通价格在价格上划条删除线.当特殊价格为空或为0时,把"特殊价格"及值隐藏而普通价格的值不划删除线.
比如我的商品有两个价格,一个是普通价格,一个是特殊价格.现在我想在商品有特殊价格时显示并且普通价格在价格上划条删除线.当特殊价格为空或为0时,把"特殊价格"及值隐藏而普通价格的值不划删除线.
sql = "select decode(特殊价格,null,'无特殊价格,则显示普通的价格','有特殊价格,显示普通价格并且有删除线的')," +
" decode(特殊价格,null,'无特殊价格,显示空','有特殊价格,显示此价格') from table ";如果你想在页面中写上述判断,那也是一样。你可在datagrid绑定之后,循环每一行,判断值
for(int i=0;i<datagrid1.Items.Count;i++)
{
普通价格 = datagrid1.Items[i].Cells[n].Text;
特殊价格 = datagrid1.Items[i].Cells[n].Text;
if(特殊价格 == "")
{
datagrid1.Items[i].Cells[n].Text = "";
}
}
前台的
<tr> <TD><B>价格:</B></TD>
<td><FONT face="宋体" color="#ff0000"><asp:label id="Label1"runat="server"></asp:label></FONT></td></tr><tr id="ItemTr1" runat="server" Visible="False"><TD><B>特价:</B></TD>
<td><FONT face="宋体" color="#ff0000"><%# DataBinder.Eval(Container.DataItem,"goodsbargainprice")%></FONT></td></tr>
后代码:在DataList1.Bind()之后
for(int i=0;i<DataList1.Items.Count;i++)
{
string strBargainprice= Goodsmain.Rows[i]["goodsbargainprice"].ToString().Trim(); string strPrice = Goodsmain.Rows[i]["goodsprice"].ToString().Trim();
if (strBargainprice!="")
{
((System.Web.UI.HtmlControls.HtmlTableRow)DataList1.Items[i].FindControl("ItemTr1")).Visible = true;
strPrice ="<u>strPrice</u>"; }
((Label)DataList1.Items[i].FindControl("Label1")).Text = strPrice;
}
以前在学校的时候是学过SQL,但都是比较基础的,根本不会在SQL语句中构造.以后也不准备在计算机方面有所发展,也没心思放在网页啊,软件啊这上边了