-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: Dhanaventh
Message 4 in Discussion


Hi,  Just check this illustration of paging in a datagrid. This should answer all ur 
issues.RegardsDan 
====================================================================<%@ Import 
Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<html>
<head>
<title>DataGrid PagerStyle Properties Example</title>
<link rel="stylesheet" href="/aspxtreme/shared/netdemos.css">

<script language="C#" runat="server" src="fetchData_oledb.cs" />

<script language="C#" runat="server">
   void Page_Load ( Object src, EventArgs e ) {
      if ( !IsPostBack ) {
         string query = "select distinct Type from Plans where not Type=''";
         typesSelect.DataSource = fetchReader ( query, "Plans" );
         typesSelect.DataBind ( );
         getPlans ( null, null );
      }
   }
   
   void setPager ( Object src, EventArgs e ) {
      plansGrid.PagerStyle.Mode = ( chkNumbers.Checked ) ?  
         PagerMode.NumericPages : PagerMode.NextPrev;

      plansGrid.PagerStyle.Position = ( chkTop.Checked ) ?  
         PagerPosition.Top : PagerPosition.Bottom;

      plansGrid.PagerStyle.Visible = ( !chkHide.Checked );

      // fetch and rebind the data.
      getPlans ( null, null );
   }

   void resetPage ( Object src, EventArgs e ) {
      // reset CurrentPageIndex
      plansGrid.CurrentPageIndex = 0;
      // fetch and rebind the data.
      getPlans ( null, null );
   }

   void getPage ( Object src, DataGridPageChangedEventArgs e ) {
      // set CurrentPageIndex to the page the user clicked.
      plansGrid.CurrentPageIndex = e.NewPageIndex;
      // fetch and rebind the data.
      getPlans ( null, null );
   }

   void getPlans ( Object src, EventArgs e ) {
      string query = "select * from Plans where Type='" + 
         typesSelect.SelectedItem + "' order by Design, PlanID";
      plansGrid.DataSource = fetchData ( query, "plans" );
      plansGrid.DataBind ( );

      lblTracker.Text = "Page " + ( plansGrid.CurrentPageIndex + 1 ) + 
         " of " + plansGrid.PageCount;
   }
</script>
</head>

<body>

<div class="header"><h3>DataGrid PagerStyle Properties Example</h3></div>

<hr size=1 width=90%>

<div align="center">
<form runat="server">

   <table cellpadding=5 width=100%>
   <tr style="font-size:8pt">
      <td>Plan Type <asp:dropdownlist id="typesSelect" runat="server" 
         datatextfield="Type" onSelectedIndexChanged="resetPage" autopostback /></td>
      <td><b><asp:label id="lblTracker" runat="server" /></b></td>
      <td align="right">
         <asp:checkbox id="chkNumbers" runat="server"
            title="Mode Property"
            text="Numeric buttons"
            autopostback 
            onCheckedChanged="setPager" />

        <asp:checkbox id="chkTop" runat="server"
            title="Position Property"
            text="Pager on Top"
            autopostback checked
            onCheckedChanged="setPager" />

        <asp:checkbox id="chkHide" runat="server"
            title="Visibility Property"
            text="Hide Pager"
            autopostback 
            onCheckedChanged="setPager" />
      </td></tr>
   </table>

   <asp:datagrid id="plansGrid" runat="server"
      width=98% cellpadding=5
      font-size="8pt"
      gridlines="horizontal"
      showheader=false
      itemstyle-verticalalign="top"
      autogeneratecolumns=false
      allowpaging pagesize=3
      onPageIndexChanged="getPage">

      <pagerstyle
         nextpagetext="Next" prevpagetext="Back"
         backcolor="navy" forecolor="lime"
         font-name="comic sans ms" font-size="9pt" font-bold
         position="top"
         pagebuttoncount=10
         horizontalalign="right" />

      <columns>

         <asp:boundcolumn 
            datafield="Design" />
         <asp:boundcolumn 
           datafield="Model" />
         <asp:boundcolumn 
            datafield="Description" />
         <asp:boundcolumn 
            datafield="PlanID"
            itemstyle-horizontalalign="right" />

         <asp:templatecolumn>
            <itemtemplate>
               <asp:hyperlink runat="server"
                  navigateurl='<%# DataBinder.Eval ( Container.DataItem, 
                     "PlanID", "details_plans.aspx?id={0}" ) %>'
                  imageurl='<%# DataBinder.Eval ( Container.DataItem, 
                     "PlanID", "~/shared/images/plans/thumbs/{0}.jpg" ) %>' 
                  tooltip='<%# ( ( DataRowView ) Container.DataItem ) [ "Model" ] %>' 
/>
            </itemtemplate>
         </asp:templatecolumn>

      </columns>

   </asp:datagrid>

</form>
</div>


</body>
</html>
=============================================================================================

  -----Original Message-----[Dhanaventh] == 
From: 
  THNQdigital [mailto:[EMAIL PROTECTED]
Sent: Thursday, February 
  26, 2004 3:30 PM
To: BDOTNET
Subject: Paging -DataGrid 
  webcontrol


  
    
      
      New Message on BDOTNET
    
      

  Paging 
    -DataGrid webcontrol


    
      
      
        Reply

        
          
            
            
               
              Reply to Sender   Recommend 
              Message 1 in 
                Discussion 
      
        
          
            
            
              From: THNQdigital 
            
              

                Hi ,
                After a datagrid webcontrol is populated from the database 
                (dataset) i implemented paging. ( allowpaging = true, allow 
                sorting = true, allow custom paging = false, page size = 10 
                etc). 

Problem description. 

After the last row 
                from the data set has been displayed, if i click next (>> 
                , the page number grows to next number and the records are shown 
                from the beginning of the dataset.. 
1) How do we stop at the 
                last record in the dataset and disable (>> and enable 
                previous (<<. )
2) How do we identify that a EOF is 
                reached in an Dataset? 
                
Please let me know
                
THNQdigital 



                 
View other groups in this 
    category. 


**********************************************************Disclaimer***************************************************************************************************************************************

This is a transmission from Ivega Corporation Private Limited (Ivega), and may contain 
information that is privileged and confidential. Ivega assumes no responsibility for 
damages resulting from unauthorized access, disclosure, tampering or delayed receipt, 
which could have occurred during transmission. If you have received this transmission 
in error, please destroy it and notify the sender immediately. 
Further, Ivega assumes no responsibility for any opinions, conclusions and other 
information in this message that do not relate to its official business. 

*************************************************************************************************************************************************************************************************************



-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to