cefriendID:cefriend
1956次访问,排名2万外好友9人,关注者13
cefriend的文章
原创 13 篇
翻译 0 篇
转载 1 篇
评论 2 篇
最近评论
dming4:未能加载文件或程序集“ASPnetPagerV2netfx2_0”或它的某一个依赖项。系统找不到指定的文件。
?????????????
conannb:收藏了 ths
文章分类
收藏
    相册
    存档
    软件项目交易
    订阅我的博客
    XML聚合  FeedSky
    订阅到鲜果
    订阅到Google
    订阅到抓虾
    订阅到BlogLines
    订阅到Yahoo
    订阅到GouGou
    订阅到飞鸽
    订阅到Rojo
    订阅到newsgator
    订阅到netvibes

    原创 Repeater的复杂使用讲解实例子收藏

    新一篇: 项目中的精华功能讲解:相信大家都用过CSDN 中结贴的功能吧(弹出的小黄窗体) | 旧一篇: (转载)做开发的人员必需要用到的------编程常用软件下载及破解

    Repeater的复杂使用讲解实例子

    在CSDN上看到大家问这到这种贴子,晚上回家想了下大概做下了

    做得不完全,给大家一种思想吧(用到的嵌套Repeater控件)有些出入,楼主可自已再改动下,

    http://topic.csdn.net/u/20080414/22/b54c735c-b2c0-4225-9a25-080d1309b168.html

     

     

    代码:

     

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test_GridView8.aspx.cs" Inherits="GridView_Test_GridView8" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        
    <title>无标题页</title>
    </head>
    <body>
        
    <form id="form1" runat="server">
            
    <asp:Repeater runat="server" ID="objRepeater">
                
    <HeaderTemplate>
                    
    <table>
                        
    <tr>
                        
    </tr>
                        
    <th>
                            供应商
    </th>
                                                
    <th width="250px">
                            供应商2
    </th>
                                                
    <th>
                            供应商3
    </th>
                                                
    <th>
                            供应商4
    </th>
                    
    </tr>s
                
    </HeaderTemplate>
                
    <ItemTemplate>
                    
    <tr>
                        
    <td>
                            
    <del>
                                
    <%#Eval("CategoryName"%>
                            
    </del>
                        
    </td>
                        
    <td>
                            
    <asp:Repeater DataSource='<%#GetChildren() %>' runat="server">
                                
    <ItemTemplate>
                                    
    <table>
                                        
    <tr>
                                            
    <td width="250px">
                                                
    <%#Eval("ProductName"%>
                                            
    </td>
                                            
    <td width="100px">
                                                
    <%#Eval("UnitPrice","{0:c}"%>
                                            
    </td>
                                            
    <td width="100px">
                                                
    <del style="background-color: Red">
                                                    
    <%#Eval("UnitsInStock","{0:c}"%>
                                                
    </del>
                                            
    </td>
                                        
    </tr>
                                    
    </table>
                                
    </ItemTemplate>
                            
    </asp:Repeater>
                        
    </td>
                    
    </tr>
                
    </ItemTemplate>
                
    <AlternatingItemTemplate>
                
    </AlternatingItemTemplate>
                
    <SeparatorTemplate>
                
    </SeparatorTemplate>
                
    <FooterTemplate>
                    
    </table>
                
    </FooterTemplate>
            
    </asp:Repeater>
        
    </form>
    </body>
    </html>

     

    后代

     

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;

    public partial class GridView_Test_GridView8 : System.Web.UI.Page
    {
        
    变量
        
    protected void Page_Load(object sender, EventArgs e)
        
    {
            
    if (!IsPostBack)
            
    {
                GetData(); 
    //加载显示的数据

            }

        }

        
    //得到Product表中的数据集
        private void GetData()
        
    {
            ds 
    = C_Categories.Instance.GetList_Eds(strSql_Categories);
            
    if (ds.Tables[0].Rows.Count > 0)
            
    {
                
    this.objRepeater.DataSource = ds.Tables[0];
                
    //objGridView.DataKeyNames = new string[] { "ProductID" };//主键(注意DataKeyNames 是复数间接告诉我们这里是可以有多个字段即可以是联合主键)
                this.objRepeater.DataBind();
            }

        }

        
    public DataSet GetChildren()
        
    {
            
    string strSql_Products = "select * from products where categoryid in (select categoryid from categories where categoryid=1)";
            
    return C_Products.Instance.GetList_Eds(strSql_Products);
        }

    }

     中间操作类方法:

     

            //常规获得记录
            public DataSet GetList_Eds(string strSql)
            
    {
                
    if (strSql != "")
                
    {
                    
    return DbHelperSql.ExecuteDataSet(strSql.ToString(), null);
                }

                
    else
                
    {
                    
    return null;
                }

            }

     

     数据库链接:

     

      <appSettings>
        
    <add key="ConnectionString" value="Persist Security Info=True;Password=sa;User ID=sa;Initial Catalog=NORTHWIND;Data Source=WANGYONGJUN" />
      
    </appSettings>
      
    <connectionStrings>
        
    <add name="NorthwindConnectionString" connectionString="Persist Security Info=True;Password=sa;User ID=sa;Initial Catalog=NORTHWIND;Data Source=WANGYONGJUN" providerName="System.Data.SqlClient" />
      
    </connectionStrings>

     

     

    发表于 @ 2008年04月16日 17:59:00|评论(loading...)|编辑

    新一篇: 项目中的精华功能讲解:相信大家都用过CSDN 中结贴的功能吧(弹出的小黄窗体) | 旧一篇: (转载)做开发的人员必需要用到的------编程常用软件下载及破解

    评论:没有评论。

    发表评论  


    当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
    Csdn Blog version 3.1a
    Copyright © cefriend