string dt = System.DateTime.Now.ToShortDateString();
string str_class = "select id,cla_time,cla_id,cla_type,cla_schedule,cla_topic,book_count from cla_daily where cla_time='" + dt + "'";SqlDataAdapter da = new SqlDataAdapter(str_class, conn);
DataSet ds = new DataSet();
da.Fill(ds);Repeater1.DataSource = ds;
Repeater1.DataBind();
现在我要根据book_count的值来绑定book_count字段, 如果book_count<8 绑定 “有位置” 否则绑定“满员”。请问需要怎样来写代码。

解决方案 »

  1.   

    select case   when book_count <8  then '有位置' else '满员' end from tb
      

  2.   

    查询结果里 有 book_count字段的值, 如果这个值<8,在gridview能显示“有位置”,如果>8则 显示 “满员”
      

  3.   

    <%#Convert.ToInt32(Eval("book_count"))<8?"有位置":"满员"%>
      

  4.   

    方法有很多
    建议你定义一Model 类
    在类内处理
    private book_count;public string Book_count
    {
      get{return book_count<8?"有位置":"满员";}
    set{book_count=value; }
    }<%#Eval("Book_count")%>
      

  5.   

    public int book_count;public string Book_count
    {
      get{return book_count<8?"有位置":"满员";}
    }
      

  6.   

    select case when book_count <8 then '有位置' else '满员' end from tb 在sql 中定义就好了..
      

  7.   

    Checked='<%# Eval("IsShow") == DbNull.Value ? false : (bool)Eval("IsShow") %>'