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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
S

Sibi Mathews

@Sibi Mathews
About
Posts
2
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • DataGrid PageIndexChangedHandler not getting called
    S Sibi Mathews

    I have the PageIndexChanged function in my cs code. And since I am creating the controls in the Page_Load() I cannot call the function in InitializeComponent. But now I found something else when the DataGrid is Populated on Page_Load itself the Paging works but when it is populated on Dropdownlist Selection Handler DataGrid Paging doesn't work. Here is my cs code....Please help me.... protected System.Web.UI.HtmlControls.HtmlForm Form1; //Object of the form same as form id in html private void Page_Load(object sender, System.EventArgs e) { SqlConnection conn = new SqlConnection("Data Source=10.0.0.245;Initial Catalog=Sibi;User Id=sa;Password=sa"); SqlDataAdapter adpt = new SqlDataAdapter("Select * from Login",conn); DataSet ds = new DataSet(); adpt.Fill(ds); DropDownList drplst = new DropDownList(); //Dropdownlist is created drplst.ID = "drplst"; drplst.AutoPostBack = true; drplst.SelectedIndexChanged +=new EventHandler (this.drplst_SelectedIndexChanged); drplst.Items.Add("Green"); drplst.Items.Add("Blue"); drplst.Items.Add("Red"); Form1.Controls.Add(drplst); DataGrid dgrid = new DataGrid(); //DataGrid is Created dgrid.ID = "dgrid"; dgrid.PageIndexChanged +=new DataGridPageChangedEventHandler(this.dgrid_PageIndexChanged); dgrid.AllowPaging = true; dgrid.PagerStyle.Mode = PagerMode.NumericPages; dgrid.PageSize = 2; Form1.Controls.Add(dgrid); dgrid.AutoGenerateColumns = false; BoundColumn name = new BoundColumn(); name.HeaderText = "NAME"; name.DataField = "Name"; dgrid.Columns.Add(name); BoundColumn Id = new BoundColumn(); Id.HeaderText = "Id"; Id.DataField = "Id"; dgrid.Columns.Add(Id); ViewState["DS"] = ds; } private void dgrid_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e) { DataGrid dgrid = (DataGrid)Form1.FindControl("dgrid"); dgrid.CurrentPageIndex = e.NewPageIndex; dgrid.DataSource = (DataSet)ViewState["DS"]; dgrid.DataBind(); } private void drplst_SelectedIndexChanged(object sender, System.EventArgs e) { DataGrid dgrid = (DataGrid)Form1.FindControl("dgrid"); dgrid.DataSource = (DataSet)ViewState["DS"]; dgrid.DataBind(); }

    ASP.NET database help question

  • DataGrid PageIndexChangedHandler not getting called
    S Sibi Mathews

    Hi all, I am facing a great problem with the Webcontrol DataGrids PageIndexChangedHandler is not getting Called. I am creating a DropDownList and a DataGrid Dynamically. The DropDownLists AutoPostBack=true. On selecting an Item in the Dropdownlist PostBack happens and Dropdownlists SelectionChanged handler gets called where the Query is fired to Database and the DataSet is assigned to DataGrid and its DataBind() is called. But the problem lies here, when you click the page index of DataGrid. The code never runs into the PageIndexChange Handler of the DataGrid. It runs through the Page_Load() and comes out. What may be the problem? Please help me out.

    ASP.NET database help question
  • Login

  • Don't have an account? Register

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