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. two datagrids on same page

two datagrids on same page

Scheduled Pinned Locked Moved ASP.NET
question
10 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.
  • R Offline
    R Offline
    robmays
    wrote on last edited by
    #1

    I have 2 grids on the same page the selectedindex fires ok on grid1 but when i swap grids using the sample code below and the user click a select on the grid2 it fires the selectedindex change event on Grid1 why wont if fire the event from grid2??? this.Panel1.Visible = false;//dtgRegion this.Panel2.Visible = true; dstFiltered = new DataSet(); dst.Tables.Clear(); dstFiltered.Tables.Add(tableFiltered); Session["FilteredTable"] = dstFiltered.Tables[0]; this.lblTotalRecords.Text = "Total leads returned = " + tableFiltered.Rows.Count.ToString(); this.dtgFiltered.DataSource = tableFiltered.DefaultView; this.dtgFiltered.DataBind();

    N E 2 Replies Last reply
    0
    • R robmays

      I have 2 grids on the same page the selectedindex fires ok on grid1 but when i swap grids using the sample code below and the user click a select on the grid2 it fires the selectedindex change event on Grid1 why wont if fire the event from grid2??? this.Panel1.Visible = false;//dtgRegion this.Panel2.Visible = true; dstFiltered = new DataSet(); dst.Tables.Clear(); dstFiltered.Tables.Add(tableFiltered); Session["FilteredTable"] = dstFiltered.Tables[0]; this.lblTotalRecords.Text = "Total leads returned = " + tableFiltered.Rows.Count.ToString(); this.dtgFiltered.DataSource = tableFiltered.DefaultView; this.dtgFiltered.DataBind();

      N Offline
      N Offline
      Norman Timo
      wrote on last edited by
      #2

      Hello robmays! It's very important how you register the events for both DataGrids. And it's important when you do this. Can you post little codesnippet where you register the SelectedIndexChanged-Events? Maybe I can help you. Ciao Norman-Timo -- modified at 10:31 Thursday 3rd November, 2005

      R 2 Replies Last reply
      0
      • R robmays

        I have 2 grids on the same page the selectedindex fires ok on grid1 but when i swap grids using the sample code below and the user click a select on the grid2 it fires the selectedindex change event on Grid1 why wont if fire the event from grid2??? this.Panel1.Visible = false;//dtgRegion this.Panel2.Visible = true; dstFiltered = new DataSet(); dst.Tables.Clear(); dstFiltered.Tables.Add(tableFiltered); Session["FilteredTable"] = dstFiltered.Tables[0]; this.lblTotalRecords.Text = "Total leads returned = " + tableFiltered.Rows.Count.ToString(); this.dtgFiltered.DataSource = tableFiltered.DefaultView; this.dtgFiltered.DataBind();

        E Offline
        E Offline
        enjoycrack
        wrote on last edited by
        #3

        robmays wrote:

        when i swap grids using the sample code below and the user click a select on the grid2 it fires the selectedindex change event on Grid1

        Maybe you forgot changing to register the event handler of SelectIndexChange for grid2 As the previous poster, you have to register event handler for both one << >>

        R 1 Reply Last reply
        0
        • E enjoycrack

          robmays wrote:

          when i swap grids using the sample code below and the user click a select on the grid2 it fires the selectedindex change event on Grid1

          Maybe you forgot changing to register the event handler of SelectIndexChange for grid2 As the previous poster, you have to register event handler for both one << >>

          R Offline
          R Offline
          robmays
          wrote on last edited by
          #4

          in the designer I selected the SelectedIndex event in the properties window for the datagrid?

          E 1 Reply Last reply
          0
          • N Norman Timo

            Hello robmays! It's very important how you register the events for both DataGrids. And it's important when you do this. Can you post little codesnippet where you register the SelectedIndexChanged-Events? Maybe I can help you. Ciao Norman-Timo -- modified at 10:31 Thursday 3rd November, 2005

            R Offline
            R Offline
            robmays
            wrote on last edited by
            #5

            All i did was select the grid then properties then event button form ther i chose the selectedindexchanged event, in the morning ill have a look at where they have been registered and how??

            1 Reply Last reply
            0
            • R robmays

              in the designer I selected the SelectedIndex event in the properties window for the datagrid?

              E Offline
              E Offline
              enjoycrack
              wrote on last edited by
              #6

              can u post ur snippet of code generated by the designer??? << >>

              R 1 Reply Last reply
              0
              • E enjoycrack

                can u post ur snippet of code generated by the designer??? << >>

                R Offline
                R Offline
                robmays
                wrote on last edited by
                #7

                private void InitializeComponent() { this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click); this.btnBlockBook.Click += new System.EventHandler(this.btnBlockBook_Click); this.btnPostcode.Click += new System.EventHandler(this.btnPostcode_Click); this.dtgLeads.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.dtgLeads_PageIndexChanged); this.dtgLeads.SelectedIndexChanged += new System.EventHandler(this.dtgLeads_SelectedIndexChanged); this.dtgFiltered.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.dtgFiltered_PageIndexChanged); this.dtgFiltered.SelectedIndexChanged += new System.EventHandler(this.dtgFiltered_SelectedIndexChanged); this.Load += new System.EventHandler(this.Page_Load); this.Init += new System.EventHandler(this.region_Init); }

                R 1 Reply Last reply
                0
                • N Norman Timo

                  Hello robmays! It's very important how you register the events for both DataGrids. And it's important when you do this. Can you post little codesnippet where you register the SelectedIndexChanged-Events? Maybe I can help you. Ciao Norman-Timo -- modified at 10:31 Thursday 3rd November, 2005

                  R Offline
                  R Offline
                  robmays
                  wrote on last edited by
                  #8

                  private void InitializeComponent() { this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click); this.btnBlockBook.Click += new System.EventHandler(this.btnBlockBook_Click); this.btnPostcode.Click += new System.EventHandler(this.btnPostcode_Click); this.dtgLeads.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.dtgLeads_PageIndexChanged); this.dtgLeads.SelectedIndexChanged += new System.EventHandler(this.dtgLeads_SelectedIndexChanged); this.dtgFiltered.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.dtgFiltered_PageIndexChanged); this.dtgFiltered.SelectedIndexChanged += new System.EventHandler(this.dtgFiltered_SelectedIndexChanged); this.Load += new System.EventHandler(this.Page_Load); this.Init += new System.EventHandler(this.region_Init); }

                  1 Reply Last reply
                  0
                  • R robmays

                    private void InitializeComponent() { this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click); this.btnBlockBook.Click += new System.EventHandler(this.btnBlockBook_Click); this.btnPostcode.Click += new System.EventHandler(this.btnPostcode_Click); this.dtgLeads.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.dtgLeads_PageIndexChanged); this.dtgLeads.SelectedIndexChanged += new System.EventHandler(this.dtgLeads_SelectedIndexChanged); this.dtgFiltered.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.dtgFiltered_PageIndexChanged); this.dtgFiltered.SelectedIndexChanged += new System.EventHandler(this.dtgFiltered_SelectedIndexChanged); this.Load += new System.EventHandler(this.Page_Load); this.Init += new System.EventHandler(this.region_Init); }

                    R Offline
                    R Offline
                    robmays
                    wrote on last edited by
                    #9

                    Silly me, because i copied and paste the one grid in the html it had the selectedindexchanged event pointing to the first grid instead of its own, I edited the html to the correct handle and all is well. I guess i was being lazy with the copy and paste but i wanted an identical grid, thats what makes programming fun.:-D

                    E 1 Reply Last reply
                    0
                    • R robmays

                      Silly me, because i copied and paste the one grid in the html it had the selectedindexchanged event pointing to the first grid instead of its own, I edited the html to the correct handle and all is well. I guess i was being lazy with the copy and paste but i wanted an identical grid, thats what makes programming fun.:-D

                      E Offline
                      E Offline
                      enjoycrack
                      wrote on last edited by
                      #10

                      Happy coding :rose:

                      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