Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Help in Automatic Paging in Datagrids and DateTime in Access

Help in Automatic Paging in Datagrids and DateTime in Access

Scheduled Pinned Locked Moved ASP.NET
questionhelpdatabase
29 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Infernojericho

    Thanks for the quick reply, Ista. Here is what I have modified the code to: objConnection.Open(); DataTable CatalogTable = new DataTable("notebook"); OleDbDataAdapter Catalogadapter = new OleDbDataAdapter(objCommand); Catalogadapter.Fill(CatalogTable); DataGridCatalog.DataSource = CatalogTable.DefaultView; DataGridCatalog.DataBind(); objConnection.Close(); The good news is that the datagrid is finally loading and displays the contents in the datagrid, the Previous and next buttons are also clickable, however, the bad news is when I clicked "next" it simply does not show the datagrid at all. There is an OnPageIndexChanged="PageChanger in my Datagrid opening tag. And the codes inside PageChanger is as follows: public void PageChanger(Object sender, DataGridPageChangedEventArgs e) { DataGridCatalog.CurrentPageIndex = e.NewPageIndex; DataGridCatalog.DataBind(); } My classmate said he used the codes above and it worked for him. What else should I be modifying? THANKS, Nick!!!

    I Offline
    I Offline
    Ista
    wrote on last edited by
    #10

    Explanation I forgot Every time you click the button it posts back So you must save the current index Then at post back set the current index Also, every postback reset the datasource and then rebind() If you extended the DataGrid you could change this behavior but lets keep it simple 1 line of code equals many bugs. So don't write any!!

    I 1 Reply Last reply
    0
    • I Infernojericho

      Thanks for the quick reply, Ista. Here is what I have modified the code to: objConnection.Open(); DataTable CatalogTable = new DataTable("notebook"); OleDbDataAdapter Catalogadapter = new OleDbDataAdapter(objCommand); Catalogadapter.Fill(CatalogTable); DataGridCatalog.DataSource = CatalogTable.DefaultView; DataGridCatalog.DataBind(); objConnection.Close(); The good news is that the datagrid is finally loading and displays the contents in the datagrid, the Previous and next buttons are also clickable, however, the bad news is when I clicked "next" it simply does not show the datagrid at all. There is an OnPageIndexChanged="PageChanger in my Datagrid opening tag. And the codes inside PageChanger is as follows: public void PageChanger(Object sender, DataGridPageChangedEventArgs e) { DataGridCatalog.CurrentPageIndex = e.NewPageIndex; DataGridCatalog.DataBind(); } My classmate said he used the codes above and it worked for him. What else should I be modifying? THANKS, Nick!!!

      I Offline
      I Offline
      Ista
      wrote on last edited by
      #11

      Set the current page index in the postback Dim iIndex as Int32 = 0 if( !postback ) if( not ViewState("Index") is nothing ) then iIndex = Convert.ToInt32( ViewState("Index") ) else iIndex = 0 DataGridCatakig.CurrentPageIndex = iIndex; end if My VB is rusty so there will be errors That should do it 1 line of code equals many bugs. So don't write any!!

      1 Reply Last reply
      0
      • I Ista

        Explanation I forgot Every time you click the button it posts back So you must save the current index Then at post back set the current index Also, every postback reset the datasource and then rebind() If you extended the DataGrid you could change this behavior but lets keep it simple 1 line of code equals many bugs. So don't write any!!

        I Offline
        I Offline
        Infernojericho
        wrote on last edited by
        #12

        I hate to be a pest but where do you set this Postback thingy? Is it in the codes of the postback function? if (Page.IsPostBack != true) { DataGridCatalog.CurrentPageIndex = e.NewPageIndex; DataGridCatalog.DataBind(); } Or is it in the properties window is Visual Studio .NET 2003? I just can't seem to find anywhere with a postback property. Sorry about all these questions but I am hell not a pro with preogramming, thanks Nick.

        I 1 Reply Last reply
        0
        • I Infernojericho

          I hate to be a pest but where do you set this Postback thingy? Is it in the codes of the postback function? if (Page.IsPostBack != true) { DataGridCatalog.CurrentPageIndex = e.NewPageIndex; DataGridCatalog.DataBind(); } Or is it in the properties window is Visual Studio .NET 2003? I just can't seem to find anywhere with a postback property. Sorry about all these questions but I am hell not a pro with preogramming, thanks Nick.

          I Offline
          I Offline
          Ista
          wrote on last edited by
          #13

          I slipped. Save the index value in the PageIndexChanged Handler(event) then set it in the postback also. goes in the handler DataGridCatalog.CurrentPageIndex = e.NewPageIndex; ViewState{"Index} = e.NewPageIndex; DataGridCatalog.DataBind(); every postback set the data source, grab the Index from the viewstate and set the current index 1 line of code equals many bugs. So don't write any!!

          I 1 Reply Last reply
          0
          • I Ista

            I slipped. Save the index value in the PageIndexChanged Handler(event) then set it in the postback also. goes in the handler DataGridCatalog.CurrentPageIndex = e.NewPageIndex; ViewState{"Index} = e.NewPageIndex; DataGridCatalog.DataBind(); every postback set the data source, grab the Index from the viewstate and set the current index 1 line of code equals many bugs. So don't write any!!

            I Offline
            I Offline
            Infernojericho
            wrote on last edited by
            #14

            Thanks for the reply. From my understanding, is it something like this: public void PageChanger(Object sender, DataGridPageChangedEventArgs e) { if (Page.IsPostBack != true) { DataGridCatalog.CurrentPageIndex = e.NewPageIndex; DataGridCatalog.DataBind(); } } and private void DataGridCatalog_SelectedIndexChanged(object sender, System.EventArgs e) { if (Page.IsPostBack != true) { Save the index value in the PageIndexChanged Handler(event) } } What is the syntax for Saving the index value anyway? Sorry if these questions sound idiotic....I really am...:( -- modified at 22:19 Wednesday 28th December, 2005

            I 1 Reply Last reply
            0
            • I Infernojericho

              Thanks for the reply. From my understanding, is it something like this: public void PageChanger(Object sender, DataGridPageChangedEventArgs e) { if (Page.IsPostBack != true) { DataGridCatalog.CurrentPageIndex = e.NewPageIndex; DataGridCatalog.DataBind(); } } and private void DataGridCatalog_SelectedIndexChanged(object sender, System.EventArgs e) { if (Page.IsPostBack != true) { Save the index value in the PageIndexChanged Handler(event) } } What is the syntax for Saving the index value anyway? Sorry if these questions sound idiotic....I really am...:( -- modified at 22:19 Wednesday 28th December, 2005

              I Offline
              I Offline
              Ista
              wrote on last edited by
              #15

              Its my fault, I confused you In the DataGridCatalog_PageIndexChanged // Dont worry about the postback here DataGridCatalog.CurrentPageIndex = e.NewPageIndex; DataGridCatalog.DataBind(); in the Page_Load // Postback only occurs here put the postback if statement I typed in the 2 answers up Then it will work. If it doesnt past those 2 code punctions in and I can look at then and see whats wrong 1 line of code equals many bugs. So don't write any!!

              I 1 Reply Last reply
              0
              • I Ista

                Its my fault, I confused you In the DataGridCatalog_PageIndexChanged // Dont worry about the postback here DataGridCatalog.CurrentPageIndex = e.NewPageIndex; DataGridCatalog.DataBind(); in the Page_Load // Postback only occurs here put the postback if statement I typed in the 2 answers up Then it will work. If it doesnt past those 2 code punctions in and I can look at then and see whats wrong 1 line of code equals many bugs. So don't write any!!

                I Offline
                I Offline
                Infernojericho
                wrote on last edited by
                #16

                Thanks again, however it seems I am unable to place e.NewPageIndex in the DateGridCatalog, since it is System.EventArgs e, not DataGridPageChangedEventArgs e. Any ideas? Thanks

                I 1 Reply Last reply
                0
                • I Infernojericho

                  Thanks again, however it seems I am unable to place e.NewPageIndex in the DateGridCatalog, since it is System.EventArgs e, not DataGridPageChangedEventArgs e. Any ideas? Thanks

                  I Offline
                  I Offline
                  Ista
                  wrote on last edited by
                  #17

                  e.NewPageIndex is a property of DataGridPageChangedEventArgs you will set the DataGridCatalor.CurrentPageIndex with the value of e.NewPageIndex. does it give you an error? paste your code so I can make sure it looks correct. 1 line of code equals many bugs. So don't write any!!

                  I 1 Reply Last reply
                  0
                  • I Ista

                    e.NewPageIndex is a property of DataGridPageChangedEventArgs you will set the DataGridCatalor.CurrentPageIndex with the value of e.NewPageIndex. does it give you an error? paste your code so I can make sure it looks correct. 1 line of code equals many bugs. So don't write any!!

                    I Offline
                    I Offline
                    Infernojericho
                    wrote on last edited by
                    #18

                    Well, I'm still quite lost and confused in the coding. Here's the code: public void PageChanger(Object sender, DataGridPageChangedEventArgs e) { if (Page.IsPostBack != true) { DataGridCatalog.CurrentPageIndex = e.NewPageIndex; DataGridCatalog.DataBind(); } } private void DataGridCatalog_SelectedIndexChanged(object sender, System.EventArgs e) { DataGridCatalog.CurrentPageIndex = e.NewPageIndex; DataGridCatalog.DataBind(); } I don't think both functions are supposed to look the same, if I placed "DataGridCatalog.CurrentPageIndex = e.NewPageIndex;" in DataGridCatalog_SelectedIndexChanged then what do I put in for the PageChanger?

                    I 2 Replies Last reply
                    0
                    • I Infernojericho

                      Well, I'm still quite lost and confused in the coding. Here's the code: public void PageChanger(Object sender, DataGridPageChangedEventArgs e) { if (Page.IsPostBack != true) { DataGridCatalog.CurrentPageIndex = e.NewPageIndex; DataGridCatalog.DataBind(); } } private void DataGridCatalog_SelectedIndexChanged(object sender, System.EventArgs e) { DataGridCatalog.CurrentPageIndex = e.NewPageIndex; DataGridCatalog.DataBind(); } I don't think both functions are supposed to look the same, if I placed "DataGridCatalog.CurrentPageIndex = e.NewPageIndex;" in DataGridCatalog_SelectedIndexChanged then what do I put in for the PageChanger?

                      I Offline
                      I Offline
                      Ista
                      wrote on last edited by
                      #19

                      delete the PageChanger 1 line of code equals many bugs. So don't write any!! -- modified at 22:40 Wednesday 28th December, 2005

                      1 Reply Last reply
                      0
                      • I Infernojericho

                        Well, I'm still quite lost and confused in the coding. Here's the code: public void PageChanger(Object sender, DataGridPageChangedEventArgs e) { if (Page.IsPostBack != true) { DataGridCatalog.CurrentPageIndex = e.NewPageIndex; DataGridCatalog.DataBind(); } } private void DataGridCatalog_SelectedIndexChanged(object sender, System.EventArgs e) { DataGridCatalog.CurrentPageIndex = e.NewPageIndex; DataGridCatalog.DataBind(); } I don't think both functions are supposed to look the same, if I placed "DataGridCatalog.CurrentPageIndex = e.NewPageIndex;" in DataGridCatalog_SelectedIndexChanged then what do I put in for the PageChanger?

                        I Offline
                        I Offline
                        Ista
                        wrote on last edited by
                        #20

                        paste your Page_Load event 1 line of code equals many bugs. So don't write any!!

                        I 1 Reply Last reply
                        0
                        • I Ista

                          paste your Page_Load event 1 line of code equals many bugs. So don't write any!!

                          I Offline
                          I Offline
                          Infernojericho
                          wrote on last edited by
                          #21

                          So that means I do not need the OnPageIndexChanged property to get it to work? I am very surprised at this. Here are the codes for the Page_Load event: public void Page_Load(object sender, System.EventArgs e) { if ((string)Session["LoginState"] == "yes") if (Page.IsPostBack != true) { //CatalogBindData(); OleDbConnection objConnection; OleDbCommand objCommand; string strConnect; string SQLSessionString = (string)Session["SQLSessionString"]; string strSQL; string CatalogCategory; strConnect = @"Provider=Microsoft.Jet.OLEDB.4.0;"; strConnect += @"Data Source = D:\Database\"; strConnect += @"Catalog.mdb ;"; strSQL = SQLSessionString + (string)Session["CatalogSortString"]; objConnection = new OleDbConnection(strConnect); objCommand = new OleDbCommand(strSQL, objConnection); objConnection.Open(); DataTable CatalogTable = new DataTable("notebook"); OleDbDataAdapter Catalogadapter = new OleDbDataAdapter(objCommand); Catalogadapter.Fill(CatalogTable); DataGridCatalog.DataSource = CatalogTable.DefaultView; DataGridCatalog.DataBind(); objConnection.Close(); } } I cannot say enough thank yous for the help, Nick. :)

                          I 3 Replies Last reply
                          0
                          • I Infernojericho

                            So that means I do not need the OnPageIndexChanged property to get it to work? I am very surprised at this. Here are the codes for the Page_Load event: public void Page_Load(object sender, System.EventArgs e) { if ((string)Session["LoginState"] == "yes") if (Page.IsPostBack != true) { //CatalogBindData(); OleDbConnection objConnection; OleDbCommand objCommand; string strConnect; string SQLSessionString = (string)Session["SQLSessionString"]; string strSQL; string CatalogCategory; strConnect = @"Provider=Microsoft.Jet.OLEDB.4.0;"; strConnect += @"Data Source = D:\Database\"; strConnect += @"Catalog.mdb ;"; strSQL = SQLSessionString + (string)Session["CatalogSortString"]; objConnection = new OleDbConnection(strConnect); objCommand = new OleDbCommand(strSQL, objConnection); objConnection.Open(); DataTable CatalogTable = new DataTable("notebook"); OleDbDataAdapter Catalogadapter = new OleDbDataAdapter(objCommand); Catalogadapter.Fill(CatalogTable); DataGridCatalog.DataSource = CatalogTable.DefaultView; DataGridCatalog.DataBind(); objConnection.Close(); } } I cannot say enough thank yous for the help, Nick. :)

                            I Offline
                            I Offline
                            Ista
                            wrote on last edited by
                            #22

                            this must be executed each time. dont put it in an if statement OleDbConnection objConnection; OleDbCommand objCommand; string strConnect; string SQLSessionString = (string)Session["SQLSessionString"]; string strSQL; string CatalogCategory; strConnect = @"Provider=Microsoft.Jet.OLEDB.4.0;"; strConnect += @"Data Source = D:\Database\"; strConnect += @"Catalog.mdb ;"; strSQL = SQLSessionString + (string)Session["CatalogSortString"]; objConnection = new OleDbConnection(strConnect); objCommand = new OleDbCommand(strSQL, objConnection); objConnection.Open(); DataTable CatalogTable = new DataTable("notebook"); OleDbDataAdapter Catalogadapter = new OleDbDataAdapter(objCommand); Catalogadapter.Fill(CatalogTable); DataGridCatalog.DataSource = CatalogTable.DefaultView; DataGridCatalog.DataBind(); objConnection.Close(); 1 line of code equals many bugs. So don't write any!!

                            1 Reply Last reply
                            0
                            • I Infernojericho

                              So that means I do not need the OnPageIndexChanged property to get it to work? I am very surprised at this. Here are the codes for the Page_Load event: public void Page_Load(object sender, System.EventArgs e) { if ((string)Session["LoginState"] == "yes") if (Page.IsPostBack != true) { //CatalogBindData(); OleDbConnection objConnection; OleDbCommand objCommand; string strConnect; string SQLSessionString = (string)Session["SQLSessionString"]; string strSQL; string CatalogCategory; strConnect = @"Provider=Microsoft.Jet.OLEDB.4.0;"; strConnect += @"Data Source = D:\Database\"; strConnect += @"Catalog.mdb ;"; strSQL = SQLSessionString + (string)Session["CatalogSortString"]; objConnection = new OleDbConnection(strConnect); objCommand = new OleDbCommand(strSQL, objConnection); objConnection.Open(); DataTable CatalogTable = new DataTable("notebook"); OleDbDataAdapter Catalogadapter = new OleDbDataAdapter(objCommand); Catalogadapter.Fill(CatalogTable); DataGridCatalog.DataSource = CatalogTable.DefaultView; DataGridCatalog.DataBind(); objConnection.Close(); } } I cannot say enough thank yous for the help, Nick. :)

                              I Offline
                              I Offline
                              Ista
                              wrote on last edited by
                              #23

                              private int Index = 0; public void Page_Load(object sender, System.EventArgs e) { if ((string)Session["LoginState"] == "yes") //CatalogBindData(); OleDbConnection objConnection; OleDbCommand objCommand; string strConnect; string SQLSessionString = (string)Session["SQLSessionString"]; string strSQL; string CatalogCategory; strConnect = @"Provider=Microsoft.Jet.OLEDB.4.0;"; strConnect += @"Data Source = D:\Database\"; strConnect += @"Catalog.mdb ;"; strSQL = SQLSessionString + (string)Session["CatalogSortString"]; objConnection = new OleDbConnection(strConnect); objCommand = new OleDbCommand(strSQL, objConnection); objConnection.Open(); DataTable CatalogTable = new DataTable("notebook"); OleDbDataAdapter Catalogadapter = new OleDbDataAdapter(objCommand); Catalogadapter.Fill(CatalogTable); DataGridCatalog.DataSource = CatalogTable.DefaultView; // now set the current index if(!IsPostBack ) { if(! ViewState["Indexc"] ) Index = Convert.ToInt32( ViewState["Index"] ); else index = 0; DataGridCatalog.CurrentPageIndex = Index; } DataGridCatalog.DataBind(); objConnection.Close(); } your PageLoaD should look like so 1 line of code equals many bugs. So don't write any!!

                              I 1 Reply Last reply
                              0
                              • I Infernojericho

                                So that means I do not need the OnPageIndexChanged property to get it to work? I am very surprised at this. Here are the codes for the Page_Load event: public void Page_Load(object sender, System.EventArgs e) { if ((string)Session["LoginState"] == "yes") if (Page.IsPostBack != true) { //CatalogBindData(); OleDbConnection objConnection; OleDbCommand objCommand; string strConnect; string SQLSessionString = (string)Session["SQLSessionString"]; string strSQL; string CatalogCategory; strConnect = @"Provider=Microsoft.Jet.OLEDB.4.0;"; strConnect += @"Data Source = D:\Database\"; strConnect += @"Catalog.mdb ;"; strSQL = SQLSessionString + (string)Session["CatalogSortString"]; objConnection = new OleDbConnection(strConnect); objCommand = new OleDbCommand(strSQL, objConnection); objConnection.Open(); DataTable CatalogTable = new DataTable("notebook"); OleDbDataAdapter Catalogadapter = new OleDbDataAdapter(objCommand); Catalogadapter.Fill(CatalogTable); DataGridCatalog.DataSource = CatalogTable.DefaultView; DataGridCatalog.DataBind(); objConnection.Close(); } } I cannot say enough thank yous for the help, Nick. :)

                                I Offline
                                I Offline
                                Ista
                                wrote on last edited by
                                #24

                                private void DataGridCatalog_SelectedIndexChanged(object sender, System.EventArgs e) { DataGridCatalog.CurrentPageIndex = e.NewPageIndex; ViewState["Index"] = e.NewPageIndex; DataGridCatalog.DataBind(); } This should look like so 1 line of code equals many bugs. So don't write any!!

                                I 2 Replies Last reply
                                0
                                • I Ista

                                  private int Index = 0; public void Page_Load(object sender, System.EventArgs e) { if ((string)Session["LoginState"] == "yes") //CatalogBindData(); OleDbConnection objConnection; OleDbCommand objCommand; string strConnect; string SQLSessionString = (string)Session["SQLSessionString"]; string strSQL; string CatalogCategory; strConnect = @"Provider=Microsoft.Jet.OLEDB.4.0;"; strConnect += @"Data Source = D:\Database\"; strConnect += @"Catalog.mdb ;"; strSQL = SQLSessionString + (string)Session["CatalogSortString"]; objConnection = new OleDbConnection(strConnect); objCommand = new OleDbCommand(strSQL, objConnection); objConnection.Open(); DataTable CatalogTable = new DataTable("notebook"); OleDbDataAdapter Catalogadapter = new OleDbDataAdapter(objCommand); Catalogadapter.Fill(CatalogTable); DataGridCatalog.DataSource = CatalogTable.DefaultView; // now set the current index if(!IsPostBack ) { if(! ViewState["Indexc"] ) Index = Convert.ToInt32( ViewState["Index"] ); else index = 0; DataGridCatalog.CurrentPageIndex = Index; } DataGridCatalog.DataBind(); objConnection.Close(); } your PageLoaD should look like so 1 line of code equals many bugs. So don't write any!!

                                  I Offline
                                  I Offline
                                  Infernojericho
                                  wrote on last edited by
                                  #25

                                  Thanks, but I am still getting errors: It seems in the statement if(!ViewState["Indexc"] ), it says Operator ! cannot be applied to operand of type 'object'. And as said earlier, I can't place e.NewPageIndex in the DataGridCatalog_SelectedIndexChanged because it is System.EventArgs e. Any ideas? Thanks

                                  I 1 Reply Last reply
                                  0
                                  • I Infernojericho

                                    Thanks, but I am still getting errors: It seems in the statement if(!ViewState["Indexc"] ), it says Operator ! cannot be applied to operand of type 'object'. And as said earlier, I can't place e.NewPageIndex in the DataGridCatalog_SelectedIndexChanged because it is System.EventArgs e. Any ideas? Thanks

                                    I Offline
                                    I Offline
                                    Ista
                                    wrote on last edited by
                                    #26

                                    first if( ViewState["Index"] == null ) will fix that Change the DataGridCatalog_Select... to private void DataGridCatalog_PageChanged( object sender. DataGridPageChangedEventArgs e ) that should fix everything SelectedIndexChanged is the default event. We dont want that event. We want the PageChanged event 1 line of code equals many bugs. So don't write any!!

                                    1 Reply Last reply
                                    0
                                    • I Ista

                                      private void DataGridCatalog_SelectedIndexChanged(object sender, System.EventArgs e) { DataGridCatalog.CurrentPageIndex = e.NewPageIndex; ViewState["Index"] = e.NewPageIndex; DataGridCatalog.DataBind(); } This should look like so 1 line of code equals many bugs. So don't write any!!

                                      I Offline
                                      I Offline
                                      Infernojericho
                                      wrote on last edited by
                                      #27

                                      Thanks for all the help. I just executed the program, there is no error messages, however, when I click on the "Next" button it simply refreshes and shows exactly the same contents as before, seems it isn't working. OleDbConnection objConnection; OleDbCommand objCommand; string strConnect; string SQLSessionString = (string)Session["SQLSessionString"]; string strSQL; string CatalogCategory; strConnect = @"Provider=Microsoft.Jet.OLEDB.4.0;"; strConnect += @"Data Source = D:\Database\"; strConnect += @"Catalog.mdb ;"; strSQL = SQLSessionString + (string)Session["CatalogSortString"]; objConnection = new OleDbConnection(strConnect); objCommand = new OleDbCommand(strSQL, objConnection); objConnection.Open(); DataTable CatalogTable = new DataTable("notebook"); OleDbDataAdapter Catalogadapter = new OleDbDataAdapter(objCommand); Catalogadapter.Fill(CatalogTable); DataGridCatalog.DataSource = CatalogTable.DefaultView; if(!IsPostBack ) { if( ViewState["Index"] == null ) { Index = Convert.ToInt32( ViewState["Index"] ); } else { Index = 0; } DataGridCatalog.CurrentPageIndex = Index; } DataGridCatalog.DataBind(); objConnection.Close(); and: private void DataGridCatalog_PageChanged( object sender, DataGridPageChangedEventArgs e ) { DataGridCatalog.CurrentPageIndex = e.NewPageIndex; ViewState["Index"] = e.NewPageIndex; DataGridCatalog.DataBind(); } What could I be missing??? Any clues? Thanks!

                                      1 Reply Last reply
                                      0
                                      • I Ista

                                        private void DataGridCatalog_SelectedIndexChanged(object sender, System.EventArgs e) { DataGridCatalog.CurrentPageIndex = e.NewPageIndex; ViewState["Index"] = e.NewPageIndex; DataGridCatalog.DataBind(); } This should look like so 1 line of code equals many bugs. So don't write any!!

                                        I Offline
                                        I Offline
                                        Infernojericho
                                        wrote on last edited by
                                        #28

                                        I think I just got it to work, Nick!!! It seems instead of using: private void DataGridCatalog_PageChanged( object sender, DataGridPageChangedEventArgs e ) { DataGridCatalog.CurrentPageIndex = e.NewPageIndex; ViewState["Index"] = e.NewPageIndex; DataGridCatalog.DataBind(); } I placed it in the PageChanger function instead. So it is like public void PageChanger(Object sender, DataGridPageChangedEventArgs e) { DataGridCatalog.CurrentPageIndex = e.NewPageIndex; ViewState["Index"] = e.NewPageIndex; DataGridCatalog.DataBind(); } After that I have placed the OnPageIndexChanged="PageChanger" in the Datagrid's opening tags. So far it seems to look fine, I am still testing it. In the meanwhile may I ask 2 simple questions? Is it possible to pass the data of a session variable via an URL in ASP.NET? and how do you align the text in a multilined textbox? I tried using
                                        and

                                        but they are displayed along with the text as well. THANKS NICK, YOU HAVE BEEN AN AWESOME HELP!!!

                                        I 1 Reply Last reply
                                        0
                                        • I Infernojericho

                                          I think I just got it to work, Nick!!! It seems instead of using: private void DataGridCatalog_PageChanged( object sender, DataGridPageChangedEventArgs e ) { DataGridCatalog.CurrentPageIndex = e.NewPageIndex; ViewState["Index"] = e.NewPageIndex; DataGridCatalog.DataBind(); } I placed it in the PageChanger function instead. So it is like public void PageChanger(Object sender, DataGridPageChangedEventArgs e) { DataGridCatalog.CurrentPageIndex = e.NewPageIndex; ViewState["Index"] = e.NewPageIndex; DataGridCatalog.DataBind(); } After that I have placed the OnPageIndexChanged="PageChanger" in the Datagrid's opening tags. So far it seems to look fine, I am still testing it. In the meanwhile may I ask 2 simple questions? Is it possible to pass the data of a session variable via an URL in ASP.NET? and how do you align the text in a multilined textbox? I tried using
                                          and

                                          but they are displayed along with the text as well. THANKS NICK, YOU HAVE BEEN AN AWESOME HELP!!!

                                          I Offline
                                          I Offline
                                          Ista
                                          wrote on last edited by
                                          #29

                                          yeah response.redirect("myasppage.aspx?mySessionValue=1") or create a html input field and make it type "hidden" then store the value Either way works. But since its in the session just get it when you need it. I use the viewstate in the same way between postbacks. Nick 1 line of code equals many bugs. So don't write any!!

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups