在cx.cs中有如下面这段sql语句:
select a.cc,a.fs,a.ds,b.fs,b.ds 
  from table a,table b 
  where a.name='aa' and b.name='bb' and a.no=b.no;
那么在cx.aspx中如何数据绑定呢?
DataBinder.Eval(Container.DataItem,?)
要将查询结果显示到页面,该如何写问号处的参数?

解决方案 »

  1.   

    select a.cc,a.fs as fs_a,a.ds as ds_a,b.fs as fs_b,b.ds as ds_b
    from table a,table b
    where a.name='aa' and b.name='bb' and a.no=b.no;
      

  2.   

    select a.cc as acc,
           a.fs as afs,
           a.ds as ads,
           b.fs as bfs,
           b.ds  as bds
      from table a,table b 
      where a.name='aa' and b.name='bb' and a.no=b.no;再绑定acc....
      

  3.   

    谢谢,我按照allen_cn的写了,可还是出错:
    System.Web.HttpException: DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name cc.
      

  4.   

    这是我的代码:
    string search_str="select a.station_train_code as cc,a.arrive_time as ft1,a.start_time as ft2,b.arrive_time as dt1,b.start_time as dt2 from stop_time a,stop_time b where a.station_name='"+sta_stop.Text+"' and b.station_name='"+end_stop.Text+"' and a.train_no=b.train_no";
      

  5.   

    string search_str="select a.station_train_code as cc,a.arrive_time as ft1,a.start_time as ft2,b.arrive_time as dt1,b.start_time as dt2 from stop_time a,stop_time b where a.station_name='"+sta_stop.Text+"' and b.station_name='"+end_stop.Text+"' and a.train_no=b.train_no";-----------
      没看出问题来!
      

  6.   

    把绑定代码再帖出来看看,你确定sql没错?
      

  7.   

    好:
    <columns>
            <asp:TemplateColumn>
              <itemtemplate>
      <asp:HyperLink  Text='<%# DataBinder.Eval(Container.DataItem,"cc")%>'   
     NavigateUrl='<%# "javascript:newwin(\"cc_search.aspx?cc="+DataBinder.Eval(Container.DataItem,"cc").ToString()+"\");" %>' runat="server"/> 
    <%# sta_stop.Text.ToString()%> 
    <%# FormatString(DataBinder.Eval(Container.DataItem, "ft1").ToString())%> 
        <%# FormatString(DataBinder.Eval(Container.DataItem, "ft2").ToString())%> 
    <%# end_stop.Text.ToString()%> 
        <%# FormatString(DataBinder.Eval(Container.DataItem, "dt1").ToString())%> 
        <%# FormatString(DataBinder.Eval(Container.DataItem, "dt2").ToString())%> 
        </itemtemplate>
            </asp:TemplateColumn>
            </columns>
      

  8.   

    应该没问题,你确定你用的sql就是select a.station_train_code as cc ..................
    是不是没有编译?????
      

  9.   

    那会重复吧?有a.arrive_time b.arrive_time
      

  10.   

    sql语句我也执行过了,能出正确的结果,奇怪拉
      

  11.   


    编译?就直接把.cs文件放到服务器上去了,还需要先编译吗?网页执行会自动编译的吧?
    ------------------------------------------------
    你改了cs文件,要重新编译一下
      

  12.   

    别名跟原来的名字一样用的 比如select * ,(select top 1 ##from table)as tt from table2 绑定的时候 绑定别名  呵呵~ 有别名就帮定别名