在做留言本,遇到与以前Asp很大区别的思维方式
我用datalist做了浏览留言,book表是记录留言的,customer表是记录用户注册信息的,现在我想在浏览留言可以显示留言之余显示用户信息,在cs窗体做了:
SqlDataAdapter sda = new SqlDataAdapter("select * from book,customer where book.cname=customer.cname order by book.id desc", one);
【中间省略】
DataList1.DataSource = ps; 绑定了数据在datalist可以用<%# DataBinder.Eval(Container.DataItem,"caddress")%> 这样方式读取数据,但是如果我要判断一个用户是男还是女的,我要怎么写呢?前台页面好像不怎么能写程序,怎样能在前台获取到对应id的性别数据来进行判断?
如果都要在后台cs窗体判断,又应该怎样关联对应的id?
我用datalist做了浏览留言,book表是记录留言的,customer表是记录用户注册信息的,现在我想在浏览留言可以显示留言之余显示用户信息,在cs窗体做了:
SqlDataAdapter sda = new SqlDataAdapter("select * from book,customer where book.cname=customer.cname order by book.id desc", one);
【中间省略】
DataList1.DataSource = ps; 绑定了数据在datalist可以用<%# DataBinder.Eval(Container.DataItem,"caddress")%> 这样方式读取数据,但是如果我要判断一个用户是男还是女的,我要怎么写呢?前台页面好像不怎么能写程序,怎样能在前台获取到对应id的性别数据来进行判断?
如果都要在后台cs窗体判断,又应该怎样关联对应的id?
<%# DataBinder.Eval(Container.DataItem,"sex").ToString() == "1" ? "男" : "女"%>
好像这样<%if(# DataBinder.Eval(Container.DataItem,"sex").ToString()=="1"){sex="男";}%>在页面判断
case
when level > 1 then ''
when level < 1 then ''
......
end as 字段名
str="case"+chr(13)+chr(10)+"when level > 1 then " +…………………… 这样?
<%# GetString(DataBinder.Eval(Container.DataItem,"caddress").ToString())%>
public string GetString(string strTemp)
{
....
return "....";
}