描述:前台显示内容,比如当是10条记录的时候我不想用.net的服务器控件,什么datalist和datagrid都不用,而是用asp的写法直接嵌到页面,哪位大哥用代码呢?
 最好是C#的,解决马上给分,分不够可以再加

解决方案 »

  1.   

    那就象asp那样写好了,在后台把dataset定义为public
      

  2.   

    用是要用的,不过你可以自己来设,代码如下:还是用到了DataGrid
    就是在DataGrid中的模板列里嵌入了table,这是我一个页面下的内容,没做修改,你自己看看吧<asp:datagrid id="MyDataGrid1" runat="server" AutoGenerateColumns="False" AllowPaging="True" Width="686px"
    CssClass="table3" ShowHeader="False" PageSize="5">
    <Columns>
    <asp:TemplateColumn>
    <ItemTemplate>
    <table width="100%" align="center" class="table0">
    <tr bgcolor="#466df4" height="30">
    <td colspan="3">
    <strong><font color="#FFFFFF">
    <%# DataBinder.Eval(Container.DataItem, "title") %>
    </font></strong>
    </td>
    </tr>
    <tr height="30">
    <td width="30%">
    <asp:Label ID ="lb0" Runat =server text='<%#DataBinder.Eval(Container.DataItem, "creat_user").ToString()%>' Visible=False>
    </asp:Label>
    <asp:Label ID ="lb1" Runat =server text='<%#person_deal(DataBinder.Eval(Container.DataItem, "creat_user").ToString())%>'>
    </asp:Label>
    <asp:Label ID ="lb2" Runat =server text='<%#user_deal(DataBinder.Eval(Container.DataItem, "creat_user").ToString())%>'>
    </asp:Label>
    </td>
    <td colspan="2">
    <%# FormatString(DataBinder.Eval(Container.DataItem, "memo").ToString())%>
    </td>
    </tr>
    <tr bgcolor="#f1f1f1" height="30">
    <td>
    <asp:Label ID ="lb3" Runat =server text='<%# DataBinder.Eval(Container.DataItem, "creat_time") %>'>
    </asp:Label>
    </td>
    <td width="50%">
    <a href='<%# DataBinder.Eval(Container.DataItem, "attach_path") %><%# DataBinder.Eval(Container.DataItem, "attach_truename") %>' target='_blank'>
    <%# DataBinder.Eval(Container.DataItem, "attach_name") %>
    </a>
    </td>
    <td width="20%" align="right" valign="bottom">
    <asp:LinkButton text="删除" Runat="server" ID="ld" CommandName="delete"></asp:LinkButton>
    </td>
    </tr>
    </table>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    <PagerStyle NextPageText="下一页" PrevPageText="上一页" HorizontalAlign="Right" CssClass="table0"></PagerStyle>
    </asp:datagrid>
      

  3.   

    没什么区别吧
    在你执行了ExecuteReader后
    可以用
    response.Write("<Table>")
    while reader.Read()
    Response.Write("<tr><td>")
    Response.Write(Reader.Item("sdf"))
    ''''
    Response.Write(Reader.Item(sdfd))'''
    Response.Write("</td></tr>")
    .....
    Response.Write("</table>")
    .....
      

  4.   

    .NET倡导的是后台代码与前台页面的分离...
    如果一定要实现分离的话,你也可以用户绑定技术.
      

  5.   

    当然,我这个是个留言版形式的,你也可以把table改成你想要的形式
      

  6.   

    <table>
    <% for(int i=0;i<10;i++){%>
    <tr><td><%=i.ToString()%></td></tr>
    <%}%>
    </table>
      

  7.   

    CssClass="table3" ShowHeader="False" PageSize="5">
    <Columns>
    <asp:TemplateColumn>
    <ItemTemplate>
    <table width="100%" align="center" class="table0">
    <tr bgcolor="#466df4" height="30">
    <td colspan="3">
    <strong><font color="#FFFFFF">
    <%# DataBinder.Eval(Container.DataItem, "title") %>
    </font></strong>
    </td>
    </tr>
    <tr height="30">
    <td width="30%">
    <asp:Label ID ="lb0" Runat =server text='<%#DataBinder.Eval(Container.DataItem, "creat_user").ToString()%>' Visible=False>
    </asp:Label>
    <asp:Label ID ="lb1" Runat =server text='<%#person_deal(DataBinder.Eval(Container.DataItem, "creat_user").ToString())%>'>
    </asp:Label>
    <asp:Label ID ="lb2" Runat =server text='<%#user_deal(DataBinder.Eval(Container.DataItem, "creat_user").ToString())%>'>
    </asp:Label>
    </td>
    <td colspan="2">
    <%# FormatString(DataBinder.Eval(Container.DataItem, "memo").ToString())%>
    </td>
    </tr>
    <tr bgcolor="#f1f1f1" height="30">
    <td>
    <asp:Label ID ="lb3" Runat =server text='<%# DataBinder.Eval(Container.DataItem, "creat_time") %>'>
    </asp:Label>
    </td>
    <td width="50%">
    <a href='<%# DataBinder.Eval(Container.DataItem, "attach_path") %><%# DataBinder.Eval(Container.DataItem, "attach_truename") %>' target='_blank'>
      

  8.   

    jijl2001(jijl2001) :请你讲话放尊重点!
     懂一点新技术有什么大不了的.
     嘴上挂着时髦东西就NBHH 的样子
      

  9.   

    搂住  你好,一般有极强控制欲望的人用Repeater  datagrid速度不快   那些人有没有想过为什么html比asp.net快?因为功能少,datagrid集成了那么多东西 速度慢。也不好控制。一般datalist是个中庸的方案。
      

  10.   

    楼主是不是在说ASP兼容模式啊?
    <%Page Language="VB" ASPCompat="True"%>
    嘿嘿,不过这就不算真正的.net了吧?
      

  11.   

    以前没有考虑过这样写法,觉得有意思,今晚尝试了以下,把以前写的新闻系统用DataList显示的改写为asp的方式,代码如下,经过测试的,你可以直接在页面上嵌上<%Today();%>就可以public void Today()
    {
    string SQL="SELECT TOP 10 News_ID,News_title FROM News_News ";string connstr=System.Configuration.ConfigurationSettings.AppSettings["strConnection"];
    SqlConnection conn=new SqlConnection(connstr);
    SqlCommand    comm=new SqlCommand(SQL,conn);
    conn.Open();
    SqlDataReader dr=comm.ExecuteReader();

    while(dr.Read())
    {

    int id=dr.GetInt32(0);
    string title=dr.GetString(1);

    Response.Write("<tr><td>");
    Response.Write("<a href='#' onclick=\"javascript:{window.open('news.aspx?id="+id.ToString()+"','see','toolbar=no,scrollbars=yes,width=820,height=600,left=120,top=50');return false;}\">");
    Response.Write(title);
    Response.Write("</a></td><tr>");

    }
    conn.Close();

    } 如果深入了解控件的人就知道了,不论是DataGrid或者是dataList只不过是把类似的方法封装起来,方便了开发,但是对速度多少有点影响~~不过我认为,牺牲一点速度换取开发的效率是值得,况且这样的速度不见得回提升多少~~~(我没有测试过)不过仔细想想,如果象163那样首页那么多的东西都用DataList对速度究竟会多大的影响呢:)
      

  12.   

    用不用asp.net的控件因人而异啦,我一般不太怎么用列表控件,方便是方便点,想改变个样式,非常的麻烦,反而直接用输出html方便点,那多控件最终就是产生html代码,何必转那多弯,自定义控件,也是采用输出html的方式!
    但后台编码是必要的,所以也不建议用response.write输出,我一般可以使用<div ruant="server"/ id="list">
    在后台用StringBuilder写它的内容,
    楼主那个很容易实现,写法和asp差不多,就是要自己写个分页的代码,得到string后
    this.list.InnerHtml=str,就可以了!
      

  13.   

    用户控件,也就是.ascx文件,往页面上拖就是了
     比asp的镶入更简单一些
      

  14.   

    <!--Include File="xx.asp"-->仍然可以使用
      

  15.   

    <TABLE id="Table1" style="HEIGHT: 300px" cellSpacing="0" cellPadding="0" width="156" border="0">
    <TR>
    <TD style="HEIGHT: 13px" align="right">
    <table cellSpacing="0" cellPadding="0" width="100%" border="0">
    <tr>
    <td vAlign="bottom" align="center" height="30"><IMG height="17" src="images/left_pic02.gif" width="87"></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    </table>
    </TD>
    </TR>
    <TR>
    <TD style="HEIGHT: 243px" vAlign="top" align="left"><FONT face="宋体"><asp:datalist id="MyList" Height="82px" Width="152px" BorderStyle="None" BorderColor="#404040"
    BackColor="Transparent" runat="server">
    <SelectedItemStyle BorderWidth="1px" BorderStyle="Solid" Width="100%" BackColor="#FFE0C0"></SelectedItemStyle>
    <SelectedItemTemplate>
    <asp:Label id="Label2" runat="server" CssClass="MenuUnselected">
    <%# DataBinder.Eval(Container.DataItem, "大类名称") %>
    </asp:Label>
    <asp:Image id="Image2" runat="server" ImageUrl="images\arrow_one.gif"></asp:Image>
    <asp:HyperLink id=Hyperlink2 runat="server" NavigateUrl='<%# "LibListForm.aspx?ClassID=" + DataBinder.Eval(Container.DataItem, "classid") + "&amp;selection=" + Container.ItemIndex %>' Text='<%# DataBinder.Eval(Container.DataItem, "小类名称") %>' cssclass="MenuUnselected">
    </asp:HyperLink>
    </SelectedItemTemplate>
    <ItemStyle HorizontalAlign="Right" BorderWidth="1px" BorderStyle="None" Width="100%"></ItemStyle>
    <ItemTemplate>
    <asp:Label id="Label1" runat="server">
    <%# DataBinder.Eval(Container.DataItem, "大类名称")%>
    </asp:Label>
    <asp:Image id="Image1" runat="server" ImageUrl="images\arrow_one.gif"></asp:Image>
    <asp:HyperLink id=HyperLink1 runat="server" NavigateUrl='<%# "LibListForm.aspx?ClassID=" + DataBinder.Eval(Container.DataItem, "classid") + "&amp;selection=" + Container.ItemIndex %>' Text='<%# DataBinder.Eval(Container.DataItem, "小类名称") %>' cssclass="MenuUnselected">
    </asp:HyperLink>
    </ItemTemplate>
    </asp:datalist></FONT></TD>
    </TR>
    <TR>
    <TD><FONT face="宋体"></FONT></TD>
    </TR>
    </TABLE>
      

  16.   

    首先你得使数据集中只有10条记录,可以在视图里写,也可以用循环控制所选ROWS。然后针对这个数据集用以下程序可以将其写到页面上:
    第一步写个表头:(仅以我机子上的一个程序为例)
    string ohtml = "";
    ohtml += "<table cellspacing=0 cellpadding=3 rules=rows bordercolor=#E7E7FF border=1  style=\"background-color:White;border-color:#E7E7FF;border-width:1px;border-style:None;width:100%;border-collapse:collapse;\">";
    ohtml += "<tr style=\"color:#F7F7F7;background-color:#4A3C8C;border-color:#77BEC0;font-size:11pt;font-weight:bold;\">";
    ohtml += "<td nowrap></td>";
    ohtml += "<td style=\"border-bottom: 2px solid #77BEC0\" nowrap> 序号</td>";
    ohtml += "<td style=\"border-bottom: 2px solid #77BEC0\" nowrap>&nbsp;收件名称</td>";
    ohtml += "<td style=\"border-bottom: 2px solid #77BEC0\" nowrap>&nbsp;收件类型</td>";
    ohtml += "<td style=\"border-bottom: 2px solid #77BEC0\" nowrap>&nbsp;份数</td>";
    ohtml += "<td style=\"border-bottom: 2px solid #77BEC0\" nowrap>&nbsp;扫描页数</td>";
    ohtml += "<td style=\"border-bottom: 2px solid #77BEC0\" nowrap>&nbsp;页码</td>";
    ohtml += "<td style=\"border-bottom: 2px solid #77BEC0\" nowrap>&nbsp;备注</td>";
    ohtml += "</tr>";
    .
    .
    .
    再写出10条记录,将其对应相应的表头:(只贴了我写的一些代码,没改,大抵思路如下)
    foreach(DataRow rs in IR.Rows)
    {
    i++;
    string rorder = rs["ROrder"].ToString();
    string recvid = rs["RecvID"].ToString();
    string rname = rs["rname"].ToString();
    string rtype = rs["rtype"].ToString();
    string copys = rs["copys"].ToString();
    string pages = rs["pages"].ToString();
    string rnum = rs["rnum"].ToString();
    string re = rs["re"].ToString();
    if(a == 0)
    {
    ohtml += "<tr style=\"color:#4A3C8C;background-color:#E7E7FF;font-size:10pt;\" id=tr"+b+">";
    a = 1;
    }
    else
    {
    ohtml += "<tr style=\"color:#4A3C8C;background-color:#F7F7F7;font-size:10pt;\" id=tr"+b+">";
    a = 0;
    }
    ohtml += "<td nowrap><a href=\"javascript: del_rec('"+recvid+"','"+rname+"');\">删</a></td>";
    ohtml += "<td nowrap><input type=text name=rorder_"+recvid+" size=1 value="+rorder+"></td>";
    ohtml += "<td nowrap><a href=\"javascript: img_rec('"+recvid+"','"+rname+"',"+pages+");\">"+rname+"</a></td>";
    ohtml += "<td nowrap><input type=text name=rtype_"+recvid+" size=2 value="+rtype+"></td>";
    ohtml += "<td nowrap><input type=text name=copys_"+recvid+" size=1 value="+copys+"></td>";
    ohtml += "<td nowrap><input type=text name=pages_"+recvid+" size=1 value="+pages+"></td>";
    ohtml += "<td nowrap><input type=text name=re_"+recvid+" size=10 value="+re+"></td>";
    ohtml += "<td nowrap><input type=text name=rnum_"+recvid+" size=5 value="+rnum+"></td>";
    ohtml += "</tr>";
    }