コード例 #1
0
        private string HandleText()
        {
            ArrayList order    = new ArrayList();
            string    template = this.ItemTemplate.Text;

            while (template.IndexOf("##DataItem(") > -1)
            {
                int EndIndex   = template.IndexOf("')##");
                int StartIndex = template.IndexOf("##DataItem('") + 12;
                order.Add(template.Substring(StartIndex, (EndIndex - StartIndex)));
                template = template.Substring(EndIndex + 4);
            }
            if (!Page.IsPostBack)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("");
                IDataReader dr = Datasource;
                dr.Read();
                int iCount    = Convert.ToInt32(dr[0]);
                int pageCount = Convert.ToInt32(Math.Ceiling(iCount / (double)this.PageSize));
                dr.NextResult();
                while (dr.Read())
                {
                    ArrayList ItemArray = new ArrayList();
                    foreach (string item in order)
                    {
                        ItemArray.Add(dr[item].ToString());
                    }
                    ItemBoundEventArgs e = new ItemBoundEventArgs(ItemArray);
                    if (ItemBound != null)
                    {
                        ItemBound(this, e);
                    }
                    foreach (string item in e.Item)
                    {
                        try
                        {
                            sb.Append(item.ToString().Replace("#", string.Empty).Replace("\"", string.Empty).Replace("\\", "\").Replace("|", "|").Replace("^", "^").Replace("'", "\\'") + this.ColDelimiter);
                        }
                        catch
                        {
                        }
                    }
                    sb.Remove((sb.Length - this.ColDelimiter.Length), this.ColDelimiter.Length);
                    sb.Append(this.RowDelimiter);
                }
                dr.Close();
                return("<script>window." + this.ClientID + ".data='" + sb.ToString() + "';window." + this.ClientID + ".PageCount=" + pageCount + ";</script>");
            }
            else
            {
                return(string.Empty);
            }
        }
コード例 #2
0
ファイル: ActiveGrid.cs プロジェクト: allanedk/ActiveForums
 private string HandleText()
 {
     ArrayList order = new ArrayList();
     string template = this.ItemTemplate.Text;
     while (template.IndexOf("##DataItem(") > -1)
     {
         int EndIndex = template.IndexOf("')##");
         int StartIndex = template.IndexOf("##DataItem('") + 12;
         order.Add(template.Substring(StartIndex, (EndIndex - StartIndex)));
         template = template.Substring(EndIndex + 4);
     }
     if (!Page.IsPostBack)
     {
         StringBuilder sb = new StringBuilder();
         sb.Append("");
         IDataReader dr = Datasource;
         dr.Read();
         int iCount = Convert.ToInt32(dr[0]);
         int pageCount = Convert.ToInt32(Math.Ceiling(iCount / (double)this.PageSize));
         dr.NextResult();
         while (dr.Read())
         {
             ArrayList ItemArray = new ArrayList();
             foreach (string item in order)
             {
                 ItemArray.Add(dr[item].ToString());
             }
             ItemBoundEventArgs e = new ItemBoundEventArgs(ItemArray);
             if (ItemBound != null)
                 ItemBound(this, e);
             foreach (string item in e.Item)
             {
                 try
                 {
                     sb.Append(item.ToString().Replace("#", string.Empty).Replace("\"", string.Empty).Replace("\\", "&#92;").Replace("|", "&#124;").Replace("^", "&#94;").Replace("'", "\\'") + this.ColDelimiter);
                 }
                 catch
                 {
                 }
                 
             }
             sb.Remove((sb.Length - this.ColDelimiter.Length), this.ColDelimiter.Length);
             sb.Append(this.RowDelimiter);
         }
         dr.Close();
         return "<script>window." + this.ClientID + ".data='" + sb.ToString() + "';window." + this.ClientID + ".PageCount=" + pageCount + ";</script>";
     }
     else
     {
         return string.Empty;
     }
 }