two datagrids on same page
-
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();
-
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();
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
-
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();
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 << >>
-
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 << >>
-
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
-
in the designer I selected the SelectedIndex event in the properties window for the datagrid?
can u post ur snippet of code generated by the designer??? << >>
-
can u post ur snippet of code generated by the designer??? << >>
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); }
-
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
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); }
-
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); }
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
-
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
Happy coding :rose: