分页控件1

  1 None.gif using  System;
  2 None.gif using  System.Web.UI;
  3 None.gif using  System.Web.UI.WebControls;
  4 None.gif using  System.ComponentModel;
  5 None.gif using  System.Drawing;
  6 None.gif
  7 None.gif namespace  DataPage
  8 ExpandedBlockStart.gifContractedBlock.gif dot.gif {
  9ExpandedSubBlockStart.gifContractedSubBlock.gif    public enum Positiondot.gif{ Front, Back}
 10ExpandedSubBlockStart.gifContractedSubBlock.gif    /**//// <summary>
 11InBlock.gif    /// WebDataPage 的摘要说明。
 12ExpandedSubBlockEnd.gif    /// </summary>

 13InBlock.gif    [DefaultProperty("Text"), 
 14InBlock.gif        ToolboxData("<{0}:WebDataPage runat=server></{0}:WebDataPage>")]
 15InBlock.gif    public class WebDataPage : System.Web.UI.WebControls.WebControl,INamingContainer
 16ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 17ContractedSubBlock.gifExpandedSubBlockStart.gif        Function#region Function
 18InBlock.gif
 19ContractedSubBlock.gifExpandedSubBlockStart.gif        GetInt#region GetInt
 20InBlock.gif        private int GetInt(object obj)
 21ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 22InBlock.gif            int iReturn = 0;
 23InBlock.gif            if( obj != null )
 24ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 25InBlock.gif                iReturn = (int)obj;
 26ExpandedSubBlockEnd.gif            }

 27InBlock.gif            return iReturn;
 28ExpandedSubBlockEnd.gif        }

 29ExpandedSubBlockEnd.gif        #endregion

 30InBlock.gif
 31ContractedSubBlock.gifExpandedSubBlockStart.gif        GetString#region GetString
 32InBlock.gif        private string GetString(string strValue)
 33ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 34InBlock.gif            return strValue;
 35ExpandedSubBlockEnd.gif        }

 36InBlock.gif        private string GetString(object obj)
 37ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 38InBlock.gif            if( obj == null )
 39ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 40InBlock.gif                return "";
 41ExpandedSubBlockEnd.gif            }

 42InBlock.gif            else
 43ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 44InBlock.gif                return obj.ToString();
 45ExpandedSubBlockEnd.gif            }

 46ExpandedSubBlockEnd.gif        }

 47ExpandedSubBlockEnd.gif        #endregion

 48InBlock.gif
 49ContractedSubBlock.gifExpandedSubBlockStart.gif        GetBoolean#region GetBoolean
 50InBlock.gif        private bool GetBoolean(object obj)
 51ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 52InBlock.gif            if( obj != null )
 53ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 54InBlock.gif                return (bool)obj;
 55ExpandedSubBlockEnd.gif            }

 56InBlock.gif            else
 57ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 58InBlock.gif                return true;
 59ExpandedSubBlockEnd.gif            }

 60ExpandedSubBlockEnd.gif        }

 61ExpandedSubBlockEnd.gif        #endregion

 62InBlock.gif
 63ContractedSubBlock.gifExpandedSubBlockStart.gif        SetDropDownListValue#region SetDropDownListValue
 64InBlock.gif        private void SetDropDownListValue(DropDownList ddl, int iValue)
 65ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 66InBlock.gif            if( ddl != null )
 67ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 68InBlock.gif                for(int i=1; i<= iValue; i++)
 69ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
 70InBlock.gif                    ListItem lst = new ListItem();
 71InBlock.gif                    lst.Value = i.ToString();
 72InBlock.gif                    lst.Text = "" +  i.ToString() + "";
 73InBlock.gif                    ddl.Items.Add( lst );
 74ExpandedSubBlockEnd.gif                }

 75ExpandedSubBlockEnd.gif            }

 76ExpandedSubBlockEnd.gif        }

 77ExpandedSubBlockEnd.gif        #endregion

 78InBlock.gif
 79ExpandedSubBlockEnd.gif        #endregion

 80InBlock.gif
 81ContractedSubBlock.gifExpandedSubBlockStart.gif        页码#region 页码
 82InBlock.gif
 83ContractedSubBlock.gifExpandedSubBlockStart.gif        PageCount 获取或设置总页数#region PageCount 获取或设置总页数
 84ExpandedSubBlockStart.gifContractedSubBlock.gif        /**//// <summary>
 85InBlock.gif        /// 获取或设置总页数
 86ExpandedSubBlockEnd.gif        /// </summary>

 87InBlock.gif        public int PageCount
 88ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 89InBlock.gif            get
 90ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 91InBlock.gif                if( PageSize == 0)
 92ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
 93InBlock.gif                    ViewState[ "PageCount" ] = 0;
 94ExpandedSubBlockEnd.gif                }

 95InBlock.gif                else
 96ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
 97InBlock.gif                    if( RecordCount % PageSize > 0 )
 98ExpandedSubBlockStart.gifContractedSubBlock.gif                    dot.gif{
 99InBlock.gif                        ViewState[ "PageCount" ] = RecordCount / PageSize + 1;
100ExpandedSubBlockEnd.gif                    }

101InBlock.gif                    else
102ExpandedSubBlockStart.gifContractedSubBlock.gif                    dot.gif{
103InBlock.gif                        ViewState[ "PageCount" ] = RecordCount / PageSize;
104ExpandedSubBlockEnd.gif                    }

105ExpandedSubBlockEnd.gif                }
    
106InBlock.gif                return GetInt( ViewState[ "PageCount" ] );
107ExpandedSubBlockEnd.gif            }

108InBlock.gif            set
109ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif
110InBlock.gif                ViewState[ "PageCount" ] = value; 
111ExpandedSubBlockEnd.gif            }

112ExpandedSubBlockEnd.gif        }

113ExpandedSubBlockEnd.gif        #endregion

114InBlock.gif
115ContractedSubBlock.gifExpandedSubBlockStart.gif        RecordCount 获取或设置记录总数#region RecordCount 获取或设置记录总数
116ExpandedSubBlockStart.gifContractedSubBlock.gif        /**//// <summary>
117InBlock.gif        /// 获取或设置记录总数
118ExpandedSubBlockEnd.gif        /// </summary>

119InBlock.gif        public int RecordCount
120ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
121InBlock.gif            get
122ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
123InBlock.gif                return GetInt( ViewState[ "RecordCount" ] );
124ExpandedSubBlockEnd.gif            }

125InBlock.gif            set
126ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif
127InBlock.gif                ViewState[ "RecordCount" ] = value; 
128ExpandedSubBlockEnd.gif            }

129ExpandedSubBlockEnd.gif        }

130ExpandedSubBlockEnd.gif        #endregion

131InBlock.gif
132ContractedSubBlock.gifExpandedSubBlockStart.gif        PageSize 设置每页显示的记录数#region PageSize 设置每页显示的记录数
133ExpandedSubBlockStart.gifContractedSubBlock.gif        /**//// <summary>
134InBlock.gif        /// 设置每页显示的记录数
135ExpandedSubBlockEnd.gif        /// </summary>

136InBlock.gif        public int PageSize
137ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
138InBlock.gif            get
139ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
140InBlock.gif                return GetInt( ViewState[ "PageSize" ] );
141ExpandedSubBlockEnd.gif            }

142InBlock.gif            set
143ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif
144InBlock.gif                ViewState[ "PageSize" ] = value; 
145ExpandedSubBlockEnd.gif            }

146ExpandedSubBlockEnd.gif        }

147ExpandedSubBlockEnd.gif        #endregion

148InBlock.gif
149ContractedSubBlock.gifExpandedSubBlockStart.gif        CurrentPageIndex 获取或设置当前页#region CurrentPageIndex 获取或设置当前页
150ExpandedSubBlockStart.gifContractedSubBlock.gif        /**//// <summary>
151InBlock.gif        /// 获取或设置当前页
152ExpandedSubBlockEnd.gif        /// </summary>

153InBlock.gif        public int CurrentPageIndex
154ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
155InBlock.gif            get
156ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
157InBlock.gif                return GetInt( ViewState[ "CurrentPageIndex" ] );
158ExpandedSubBlockEnd.gif            }

159InBlock.gif            set
160ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif
161InBlock.gif                ViewState[ "CurrentPageIndex" ] = value; 
162ExpandedSubBlockEnd.gif            }

163ExpandedSubBlockEnd.gif        }

164ExpandedSubBlockEnd.gif        #endregion

165InBlock.gif
166ExpandedSubBlockEnd.gif        #endregion

167InBlock.gif
168ContractedSubBlock.gifExpandedSubBlockStart.gif        信息是否显示#region 信息是否显示
169InBlock.gif
170ContractedSubBlock.gifExpandedSubBlockStart.gif        RecordCountIsVisible 总共N条记录是否显示#region RecordCountIsVisible 总共N条记录是否显示
171ExpandedSubBlockStart.gifContractedSubBlock.gif        /**//// <summary>
172InBlock.gif        /// 总共N条记录是否显示
173ExpandedSubBlockEnd.gif        /// </summary>

174InBlock.gif        public bool RecordCountIsVisible
175ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
176InBlock.gif            get
177ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
178InBlock.gif                return GetBoolean( ViewState[ "RecordCountIsVisible" ] ); 
179ExpandedSubBlockEnd.gif            }

180InBlock.gif            set
181ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif
182InBlock.gif                ViewState[ "RecordCountIsVisible" ] = value; 
183ExpandedSubBlockEnd.gif            }

184ExpandedSubBlockEnd.gif        }

185ExpandedSubBlockEnd.gif        #endregion

186InBlock.gif
187ContractedSubBlock.gifExpandedSubBlockStart.gif        PageCountIsVisible 共N页是否显示#region PageCountIsVisible 共N页是否显示
188ExpandedSubBlockStart.gifContractedSubBlock.gif        /**//// <summary>
189InBlock.gif        /// 共N页是否显示
190ExpandedSubBlockEnd.gif        /// </summary>

191InBlock.gif        public bool PageCountIsVisible
192ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
193InBlock.gif            get
194ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
195InBlock.gif                return GetBoolean( ViewState[ "PageCountIsVisible" ] ); 
196ExpandedSubBlockEnd.gif            }

197InBlock.gif            set
198ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif
199InBlock.gif                ViewState[ "PageCountIsVisible" ] = value; 
200ExpandedSubBlockEnd.gif            }

201ExpandedSubBlockEnd.gif        }

202ExpandedSubBlockEnd.gif        #endregion

203InBlock.gif
204ContractedSubBlock.gifExpandedSubBlockStart.gif        CurrentPageIndexIsVisible 第N页是否显示#region CurrentPageIndexIsVisible 第N页是否显示
205ExpandedSubBlockStart.gifContractedSubBlock.gif        /**//// <summary>
206InBlock.gif        /// 第N页是否显示
207ExpandedSubBlockEnd.gif        /// </summary>

208InBlock.gif        public bool CurrentPageIndexIsVisible
209ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
210InBlock.gif            get
211ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
212InBlock.gif                return GetBoolean( ViewState[ "CurrentPageIndexIsVisible" ] ); 
213ExpandedSubBlockEnd.gif            }

214InBlock.gif            set
215ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif
216InBlock.gif                ViewState[ "CurrentPageIndexIsVisible" ] = value; 
217ExpandedSubBlockEnd.gif            }

218ExpandedSubBlockEnd.gif        }

219ExpandedSubBlockEnd.gif        #endregion

220InBlock.gif
221ContractedSubBlock.gifExpandedSubBlockStart.gif        FirstPageIsVisible 首页是否显示#region FirstPageIsVisible 首页是否显示
222ExpandedSubBlockStart.gifContractedSubBlock.gif        /**//// <summary>
223InBlock.gif        /// 首页是否显示
224ExpandedSubBlockEnd.gif        /// </summary>

225InBlock.gif        public bool FirstPageIsVisible
226ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
227InBlock.gif            get
228ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
229InBlock.gif                return GetBoolean( ViewState[ "FirstPageIsVisible" ] ); 
230ExpandedSubBlockEnd.gif            }

231InBlock.gif            set
232ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif
233InBlock.gif                ViewState[ "FirstPageIsVisible" ] = value; 
234ExpandedSubBlockEnd.gif            }

235ExpandedSubBlockEnd.gif        }

236ExpandedSubBlockEnd.gif        #endregion

237InBlock.gif
238ContractedSubBlock.gifExpandedSubBlockStart.gif        PrevPageIsVisible 上一页是否显示#region PrevPageIsVisible 上一页是否显示
239ExpandedSubBlockStart.gifContractedSubBlock.gif        /**//// <summary>
240InBlock.gif        /// 上一页是否显示
241ExpandedSubBlockEnd.gif        /// </summary>

242InBlock.gif        public bool PrevPageIsVisible
243ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
244InBlock.gif            get
245ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
246InBlock.gif                return GetBoolean( ViewState[ "PrevPageIsVisible" ] ); 
247ExpandedSubBlockEnd.gif            }

248InBlock.gif            set
249ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif
250InBlock.gif                ViewState[ "PrevPageIsVisible" ] = value; 
251ExpandedSubBlockEnd.gif            }

252ExpandedSubBlockEnd.gif        }

253ExpandedSubBlockEnd.gif        #endregion

254InBlock.gif
255ContractedSubBlock.gifExpandedSubBlockStart.gif        NextPageIsVisible 下一页是否显示#region NextPageIsVisible 下一页是否显示
256ExpandedSubBlockStart.gifContractedSubBlock.gif        /**//// <summary>
257InBlock.gif        /// 下一页是否显示
258ExpandedSubBlockEnd.gif        /// </summary>

259InBlock.gif        public bool NextPageIsVisible
260ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
261InBlock.gif            get
262ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
263InBlock.gif                return GetBoolean( ViewState[ "NextPageIsVisible" ] ); 
264ExpandedSubBlockEnd.gif            }

265InBlock.gif            set
266ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif
267InBlock.gif                ViewState[ "NextPageIsVisible" ] = value; 
268ExpandedSubBlockEnd.gif            }

269ExpandedSubBlockEnd.gif        }

270ExpandedSubBlockEnd.gif        #endregion

271InBlock.gif
272ContractedSubBlock.gifExpandedSubBlockStart.gif        LastPageIsVisible 最后一页是否显示#region LastPageIsVisible 最后一页是否显示
273ExpandedSubBlockStart.gifContractedSubBlock.gif        /**//// <summary>
274InBlock.gif        /// 最后一页是否显示
275ExpandedSubBlockEnd.gif        /// </summary>

276InBlock.gif        public bool LastPageIsVisible
277ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
278InBlock.gif            get
279ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
280InBlock.gif                return GetBoolean( ViewState[ "LastPageIsVisible" ] ); 
281ExpandedSubBlockEnd.gif            }

282InBlock.gif            set
283ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif
284InBlock.gif                ViewState[ "LastPageIsVisible" ] = value; 
285ExpandedSubBlockEnd.gif            }

286ExpandedSubBlockEnd.gif        }

287ExpandedSubBlockEnd.gif        #endregion

288InBlock.gif
289ContractedSubBlock.gifExpandedSubBlockStart.gif        SelectPageIsVisible 下拉列表框是否显示#region SelectPageIsVisible 下拉列表框是否显示
290ExpandedSubBlockStart.gifContractedSubBlock.gif        /**//// <summary>
291InBlock.gif        /// 下拉列表框是否显示
292ExpandedSubBlockEnd.gif        /// </summary>

293InBlock.gif        public bool SelectPageIsVisible
294ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
295InBlock.gif            get
296ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
297InBlock.gif                return GetBoolean( ViewState[ "SelectPageIsVisible" ] ); 
298ExpandedSubBlockEnd.gif            }

299InBlock.gif            set
300ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif
301InBlock.gif                ViewState[ "SelectPageIsVisible" ] = value; 
302ExpandedSubBlockEnd.gif            }

303ExpandedSubBlockEnd.gif        }

304ExpandedSubBlockEnd.gif        #endregion

305InBlock.gif
306ExpandedSubBlockEnd.gif        #endregion

307InBlock.gif
308ContractedSubBlock.gifExpandedSubBlockStart.gif        文本内容#region 文本内容
309InBlock.gif
310ContractedSubBlock.gifExpandedSubBlockStart.gif        FirstPageText 首页文本内容#region FirstPageText 首页文本内容
311ExpandedSubBlockStart.gifContractedSubBlock.gif        /**//// <summary>
312InBlock.gif        /// 首页文本内容
313ExpandedSubBlockEnd.gif        /// </summary>

314InBlock.gif        public string FirstPageText
315ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
316InBlock.gif            get
317ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
318InBlock.gif                return GetString( ViewState[ "FirstPageText" ] ); 
319ExpandedSubBlockEnd.gif            }

320InBlock.gif            set
321ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif
322InBlock.gif                ViewState[ "FirstPageText" ] = value; 
323ExpandedSubBlockEnd.gif            }

324ExpandedSubBlockEnd.gif        }

325ExpandedSubBlockEnd.gif        #endregion

326InBlock.gif
327ContractedSubBlock.gifExpandedSubBlockStart.gif        PrevPageText 上一页文本内容#region PrevPageText 上一页文本内容
328ExpandedSubBlockStart.gifContractedSubBlock.gif        /**//// <summary>
329InBlock.gif        /// 上一页文本内容
330ExpandedSubBlockEnd.gif        /// </summary>

331InBlock.gif        public string PrevPageText
332ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
333InBlock.gif            get
334ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
335InBlock.gif                return GetString( ViewState[ "PrevPageText" ] ); 
336ExpandedSubBlockEnd.gif            }

337InBlock.gif            set
338ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif
339InBlock.gif                ViewState[ "PrevPageText" ] = value; 
340ExpandedSubBlockEnd.gif            }

341ExpandedSubBlockEnd.gif        }

342ExpandedSubBlockEnd.gif        #endregion

343InBlock.gif
344ContractedSubBlock.gifExpandedSubBlockStart.gif        NextPageText 下一页文本内容#region NextPageText 下一页文本内容
345ExpandedSubBlockStart.gifContractedSubBlock.gif        /**//// <summary>
346InBlock.gif        /// 下一页文本内容
347ExpandedSubBlockEnd.gif        /// </summary>

348InBlock.gif        public string NextPageText
349ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
350InBlock.gif            get
351ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
352InBlock.gif                return GetString( ViewState[ "NextPageText" ] ); 
353ExpandedSubBlockEnd.gif            }

354InBlock.gif            set
355ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif
356InBlock.gif                ViewState[ "NextPageText" ] = value; 
357ExpandedSubBlockEnd.gif            }

358ExpandedSubBlockEnd.gif        }

359ExpandedSubBlockEnd.gif        #endregion

360InBlock.gif
361ContractedSubBlock.gifExpandedSubBlockStart.gif        LastPageText 最后一页文本内容#region LastPageText 最后一页文本内容
362ExpandedSubBlockStart.gifContractedSubBlock.gif        /**//// <summary>
363InBlock.gif        /// 最后一页文本内容
364ExpandedSubBlockEnd.gif        /// </summary>

365InBlock.gif        public string LastPageText
366ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
367InBlock.gif            get
368ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
369InBlock.gif                return GetString( ViewState[ "LastPageText" ] ); 
370ExpandedSubBlockEnd.gif            }

371InBlock.gif            set
372ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif
373InBlock.gif                ViewState[ "LastPageText" ] = value; 
374ExpandedSubBlockEnd.gif            }

375ExpandedSubBlockEnd.gif        }

376ExpandedSubBlockEnd.gif        #endregion

377InBlock.gif
378ExpandedSubBlockEnd.gif        #endregion

379InBlock.gif
380ContractedSubBlock.gifExpandedSubBlockStart.gif        获取或设置下拉列表框的位置#region 获取或设置下拉列表框的位置
381InBlock.gif        public Position SelectPosition
382ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
383InBlock.gif            get
384ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
385InBlock.gif                if( ViewState["SelectPosition"== null )
386ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
387InBlock.gif                    return Position.Back;
388ExpandedSubBlockEnd.gif                }

389InBlock.gif                else
390ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
391InBlock.gif                    return (Position)ViewState["SelectPosition"];
392ExpandedSubBlockEnd.gif                }

393ExpandedSubBlockEnd.gif            }

394InBlock.gif            set
395ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
396InBlock.gif                ViewState["SelectPosition"= value;
397ExpandedSubBlockEnd.gif            }

398ExpandedSubBlockEnd.gif        }

399ExpandedSubBlockEnd.gif        #endregion

400InBlock.gif        
401InBlock.gif
402ContractedSubBlock.gifExpandedSubBlockStart.gif        CreateChildControls#region CreateChildControls
403InBlock.gif        protected override void CreateChildControls()
404ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
405InBlock.gif            this.Controls.Clear();
406InBlock.gif            //Tanle
407InBlock.gif            Table tb = new Table();
408InBlock.gif            tb.ID = "tb";
409InBlock.gif            this.Controls.Add( tb );
410InBlock.gif            tb.Width = Unit.Percentage(100);
411InBlock.gif            
412InBlock.gif            //tr
413InBlock.gif            TableRow row = new TableRow();
414InBlock.gif            row.ID = "row";
415InBlock.gif            tb.Rows.Add( row );
416InBlock.gif
417ContractedSubBlock.gifExpandedSubBlockStart.gif            总共N条记录#region 总共N条记录
418InBlock.gif            TableCell cellRecordCount = new TableCell();
419InBlock.gif            cellRecordCount.ID = "cellRecordCount";
420InBlock.gif            row.Cells.Add( cellRecordCount );
421InBlock.gif            cellRecordCount.VerticalAlign = VerticalAlign.Middle;
422InBlock.gif            cellRecordCount.HorizontalAlign = HorizontalAlign.Center;
423InBlock.gif            if( RecordCountIsVisible )
424ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
425InBlock.gif                LiteralControl lcRecordCount = new LiteralControl();
426InBlock.gif                lcRecordCount.ID = "lcRecordCount";
427InBlock.gif                cellRecordCount.Controls.Add( lcRecordCount );
428InBlock.gif                lcRecordCount.Text = "总共&nbsp;" + RecordCount.ToString() + "&nbsp;条记录";
429ExpandedSubBlockEnd.gif            }

430ExpandedSubBlockEnd.gif            #endregion

431InBlock.gif
432ContractedSubBlock.gifExpandedSubBlockStart.gif            共N页#region 共N页
433InBlock.gif            TableCell cellPageCount = new TableCell();
434InBlock.gif            cellPageCount.ID = "cellPageCount";
435InBlock.gif            row.Cells.Add( cellPageCount );
436InBlock.gif            cellPageCount.VerticalAlign = VerticalAlign.Middle;
437InBlock.gif            cellPageCount.HorizontalAlign = HorizontalAlign.Center;
438InBlock.gif            if( PageCountIsVisible )
439ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
440InBlock.gif                LiteralControl lcPageCount = new LiteralControl();
441InBlock.gif                lcPageCount.ID = "lcPageCount";
442InBlock.gif                cellPageCount.Controls.Add( lcPageCount );
443InBlock.gif                lcPageCount.Text = "共&nbsp;" + PageCount.ToString() + "&nbsp;页";
444ExpandedSubBlockEnd.gif            }

445ExpandedSubBlockEnd.gif            #endregion

446InBlock.gif
447ContractedSubBlock.gifExpandedSubBlockStart.gif            第N页#region 第N页
448InBlock.gif            TableCell cellCurrentPageIndex = new TableCell();
449InBlock.gif            cellCurrentPageIndex.ID = "cellCurrentPageIndex";
450InBlock.gif            row.Cells.Add( cellCurrentPageIndex );
451InBlock.gif            cellCurrentPageIndex.VerticalAlign = VerticalAlign.Middle;
452InBlock.gif            cellCurrentPageIndex.HorizontalAlign = HorizontalAlign.Center;
453InBlock.gif            if( CurrentPageIndexIsVisible )
454ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
455InBlock.gif                LiteralControl lcCurrentPageIndex = new LiteralControl();
456InBlock.gif                lcCurrentPageIndex.ID = "lcCurrentPageIndex";
457InBlock.gif                cellCurrentPageIndex.Controls.Add( lcCurrentPageIndex );
458InBlock.gif                lcCurrentPageIndex.Text = "第&nbsp;" + CurrentPageIndex.ToString() + "&nbsp;页";
459ExpandedSubBlockEnd.gif            }

460ExpandedSubBlockEnd.gif            #endregion

461InBlock.gif
462ContractedSubBlock.gifExpandedSubBlockStart.gif            首页#region 首页
463InBlock.gif            TableCell cellFirstPage = new TableCell();
464InBlock.gif            cellFirstPage.ID = "cellFirstPage";
465InBlock.gif            row.Cells.Add( cellFirstPage );
466InBlock.gif            cellFirstPage.VerticalAlign = VerticalAlign.Middle;
467InBlock.gif            cellFirstPage.HorizontalAlign = HorizontalAlign.Center;
468InBlock.gif            if( FirstPageIsVisible )
469ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
470InBlock.gif                LinkButton lbtnFirstPage = new LinkButton();
471InBlock.gif                lbtnFirstPage.ID= "lbtnFirstPage";
472InBlock.gif                cellFirstPage.Controls.Add( lbtnFirstPage );
473InBlock.gif                lbtnFirstPage.Click +=new EventHandler(lbtnFirstPage_Click);
474InBlock.gif                if( FirstPageText.Length > 0 )
475ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
476InBlock.gif                    lbtnFirstPage.Text = FirstPageText;
477ExpandedSubBlockEnd.gif                }

478InBlock.gif                else
479ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
480InBlock.gif                    lbtnFirstPage.Text = "首页";
481ExpandedSubBlockEnd.gif                }

482ExpandedSubBlockEnd.gif            }

483ExpandedSubBlockEnd.gif            #endregion

484InBlock.gif
485ContractedSubBlock.gifExpandedSubBlockStart.gif            上一页#region 上一页
486InBlock.gif            TableCell cellPrevPage = new TableCell();
487InBlock.gif            cellPrevPage.ID = "cellPrevPage";
488InBlock.gif            row.Cells.Add( cellPrevPage );
489InBlock.gif            cellPrevPage.VerticalAlign = VerticalAlign.Middle;
490InBlock.gif            cellPrevPage.HorizontalAlign = HorizontalAlign.Center;
491InBlock.gif            if( PrevPageIsVisible )
492ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
493InBlock.gif                LinkButton lbtnPrevPage= new LinkButton();
494InBlock.gif                lbtnPrevPage.ID = "lbtnPrevPage";
495InBlock.gif                cellPrevPage.Controls.Add( lbtnPrevPage );
496InBlock.gif                lbtnPrevPage.Click +=new EventHandler(lbtnPrevPage_Click);
497InBlock.gif                if( PrevPageText.Length > 0 )
498ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
499InBlock.gif                    lbtnPrevPage.Text = PrevPageText;
500ExpandedSubBlockEnd.gif                }

501InBlock.gif                else
502ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
503InBlock.gif                    lbtnPrevPage.Text = "上一页";
504ExpandedSubBlockEnd.gif                }

505ExpandedSubBlockEnd.gif            }

506ExpandedSubBlockEnd.gif            #endregion

507InBlock.gif            
508ContractedSubBlock.gifExpandedSubBlockStart.gif            下一页#region 下一页
509InBlock.gif            TableCell cellNextPage = new TableCell();
510InBlock.gif            cellNextPage.ID = "cellNextPage";
511InBlock.gif            row.Cells.Add( cellNextPage );
512InBlock.gif            cellNextPage.VerticalAlign = VerticalAlign.Middle;
513InBlock.gif            cellNextPage.HorizontalAlign = HorizontalAlign.Center;
514InBlock.gif            if( NextPageIsVisible )
515ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
516InBlock.gif                LinkButton lbtnNextPage = new LinkButton();
517InBlock.gif                lbtnNextPage.ID= "lbtnNextPage";
518InBlock.gif                cellNextPage.Controls.Add( lbtnNextPage );
519InBlock.gif                lbtnNextPage.Click +=new EventHandler(lbtnNextPage_Click);
520InBlock.gif                if( NextPageText.Length > 0 )
521ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
522InBlock.gif                    lbtnNextPage.Text = NextPageText;
523ExpandedSubBlockEnd.gif                }

524InBlock.gif                else
525ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
526InBlock.gif                    lbtnNextPage.Text = "下一页";
527ExpandedSubBlockEnd.gif                }

528ExpandedSubBlockEnd.gif            }

529ExpandedSubBlockEnd.gif            #endregion

530InBlock.gif
531ContractedSubBlock.gifExpandedSubBlockStart.gif            最后一页#region 最后一页
532InBlock.gif            TableCell cellLastPage = new TableCell();
533InBlock.gif            cellLastPage.ID = "cellLastPage";
534InBlock.gif            row.Cells.Add( cellLastPage );
535InBlock.gif            cellLastPage.VerticalAlign = VerticalAlign.Middle;
536InBlock.gif            cellLastPage.HorizontalAlign = HorizontalAlign.Center;
537InBlock.gif            if( LastPageIsVisible )
538ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
539InBlock.gif                LinkButton lbtnLastPage = new LinkButton();
540InBlock.gif                lbtnLastPage.ID = "lbtnLastPage";
541InBlock.gif                cellLastPage.Controls.Add( lbtnLastPage );
542InBlock.gif                lbtnLastPage.Click +=new EventHandler(lbtnLastPage_Click);
543InBlock.gif                if( LastPageText.Length > 0 )
544ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
545InBlock.gif                    lbtnLastPage.Text = LastPageText;
546ExpandedSubBlockEnd.gif                }

547InBlock.gif                else
548ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
549InBlock.gif                    lbtnLastPage.Text = "最后一页";
550ExpandedSubBlockEnd.gif                }

551ExpandedSubBlockEnd.gif            }

552ExpandedSubBlockEnd.gif            #endregion

553InBlock.gif
554ContractedSubBlock.gifExpandedSubBlockStart.gif            选择页码#region 选择页码
555InBlock.gif            if( SelectPageIsVisible )
556ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
557InBlock.gif                TableCell cellSelectPage = new TableCell();
558InBlock.gif                cellSelectPage.ID = "cellSelectPage";
559InBlock.gif                if( SelectPosition == Position.Front )
560ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
561InBlock.gif                    row.Cells.AddAt(0, cellSelectPage);
562ExpandedSubBlockEnd.gif                }

563InBlock.gif                else
564ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
565InBlock.gif                    row.Cells.Add( cellSelectPage );
566ExpandedSubBlockEnd.gif                }

567InBlock.gif                cellSelectPage.VerticalAlign = VerticalAlign.Middle;
568InBlock.gif                cellSelectPage.HorizontalAlign = HorizontalAlign.Center;
569InBlock.gif
570InBlock.gif                DropDownList ddlSelectPage = new DropDownList();
571InBlock.gif                ddlSelectPage.ID = "ddlSelectPage";
572InBlock.gif                cellSelectPage.Controls.Add( ddlSelectPage );
573InBlock.gif                SetDropDownListValue( ddlSelectPage, PageCount );
574InBlock.gif                ddlSelectPage.SelectedIndex = CurrentPageIndex - 1;
575InBlock.gif                ddlSelectPage.AutoPostBack = true;
576InBlock.gif                ddlSelectPage.SelectedIndexChanged +=new EventHandler(ddlSelectPage_SelectedIndexChanged);
577ExpandedSubBlockEnd.gif            }

578InBlock.gif            
579ExpandedSubBlockEnd.gif            #endregion

580InBlock.gif
581InBlock.gif            base.CreateChildControls ();
582ExpandedSubBlockEnd.gif        }

583ExpandedSubBlockEnd.gif        #endregion

584InBlock.gif
585ContractedSubBlock.gifExpandedSubBlockStart.gif        Change Pageindex#region Change Pageindex
586InBlock.gif
587ContractedSubBlock.gifExpandedSubBlockStart.gif        首页#region 首页
588InBlock.gif        private void lbtnFirstPage_Click(object sender, EventArgs e)
589ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
590InBlock.gif            CurrentPageIndex = 1;
591InBlock.gif            CreateChildControls();
592InBlock.gif            SendPageChanged();
593ExpandedSubBlockEnd.gif        }

594ExpandedSubBlockEnd.gif        #endregion

595InBlock.gif
596ContractedSubBlock.gifExpandedSubBlockStart.gif        上一页#region 上一页
597InBlock.gif        private void lbtnPrevPage_Click(object sender, EventArgs e)
598ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
599InBlock.gif            if( CurrentPageIndex > 1)
600ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
601InBlock.gif                CurrentPageIndex = CurrentPageIndex - 1;
602ExpandedSubBlockEnd.gif            }

603InBlock.gif            CreateChildControls();
604InBlock.gif            SendPageChanged();
605ExpandedSubBlockEnd.gif        }

606ExpandedSubBlockEnd.gif        #endregion

607InBlock.gif
608ContractedSubBlock.gifExpandedSubBlockStart.gif        下一页#region 下一页
609InBlock.gif        private void lbtnNextPage_Click(object sender, EventArgs e)
610ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
611InBlock.gif            if( CurrentPageIndex < PageCount )
612ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
613InBlock.gif                CurrentPageIndex = CurrentPageIndex + 1;
614ExpandedSubBlockEnd.gif            }

615InBlock.gif            CreateChildControls();
616InBlock.gif            SendPageChanged();
617ExpandedSubBlockEnd.gif        }

618ExpandedSubBlockEnd.gif        #endregion

619InBlock.gif
620ContractedSubBlock.gifExpandedSubBlockStart.gif        最后一页#region 最后一页
621InBlock.gif        private void lbtnLastPage_Click(object sender, EventArgs e)
622ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
623InBlock.gif            CurrentPageIndex = PageCount;
624InBlock.gif            CreateChildControls();
625InBlock.gif            SendPageChanged();
626ExpandedSubBlockEnd.gif        }

627ExpandedSubBlockEnd.gif        #endregion

628InBlock.gif
629ContractedSubBlock.gifExpandedSubBlockStart.gif        选择页码#region 选择页码
630InBlock.gif        private void ddlSelectPage_SelectedIndexChanged(object sender, EventArgs e)
631ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
632InBlock.gif            DropDownList ddlSelectPage = sender as DropDownList;
633InBlock.gif            if( ddlSelectPage != null )
634ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
635InBlock.gif                CurrentPageIndex = Convert.ToInt32( ddlSelectPage.SelectedValue );
636InBlock.gif                CreateChildControls();
637InBlock.gif                SendPageChanged();
638ExpandedSubBlockEnd.gif            }

639ExpandedSubBlockEnd.gif        }

640ExpandedSubBlockEnd.gif        #endregion

641InBlock.gif
642ExpandedSubBlockEnd.gif        #endregion

643InBlock.gif    
644ContractedSubBlock.gifExpandedSubBlockStart.gif        Event PageChanged#region Event PageChanged
645InBlock.gif        public event EventHandler PageChanged;
646ExpandedSubBlockEnd.gif        #endregion

647InBlock.gif
648ContractedSubBlock.gifExpandedSubBlockStart.gif        SendPageChange#region SendPageChange
649InBlock.gif        private void SendPageChanged()
650ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
651InBlock.gif            if(PageChanged != null)
652ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
653InBlock.gif                PageChanged(this,EventArgs.Empty);
654ExpandedSubBlockEnd.gif            }

655ExpandedSubBlockEnd.gif        }

656ExpandedSubBlockEnd.gif        #endregion

657InBlock.gif
658InBlock.gif
659ExpandedSubBlockEnd.gif    }

660ExpandedBlockEnd.gif}

661 None.gif
使用方法:
ExpandedBlockStart.gif ContractedBlock.gif <% dot.gif @ Register TagPrefix="cc1" Namespace="DataPage" Assembly="DataPage"  %>
None.gif < cc1:WebDataPage  id ="WebDataPage1"  runat ="server" ></ cc1:WebDataPage >

转载于:https://www.cnblogs.com/timsoft/articles/637064.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值