We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 101,253 times

Contents

Downloads

Related Categories

Web Forms DataGrid and DataSet Programming - FAQ's

Jeff_Louie

FAQ's

Q. Why doesn't my default GridLayout project display correctly in Netscape 4.7.
A . For maximum compatibility, try building your project using FlowLayout and nested tables.

Q. Why doesn't my DataGrid show up when I run the project? I can see it in the design view.
A. You need to fill the DataSet and call DataBind in Page_Load.

sqlDataAdapter1.Fill(dataSet11);
...
DataGrid1.DataBind();

Q. Why are all of my changes lost on post back?
A. Don't call DataBind except on the initial page load or in your event handlers, allowing the grid to be repopulated from the ViewState.

// This code executes every time
sqlDataAdapter1.Fill(dataSet11);
// This code executes the first time only
if (!IsPostBack)
{
    DataGrid1.DataBind();
}

Q. Why can't I debug?
A. Under IIS Properties --> Directory Security --> Anonymous Access Edit --> Enable Integrated Windows Authentication.

Q. Why do I need a logon password to access a web page directly from IE?
A. Enable Guest Account ant then under Control Panel --> User Accounts --> Change an Account --> Guest --> Remove the password.

Q. How do I turn off auto formatting in the HTML view?
A. Go to Tools --> Options... --> Text Editor --> HTML/XML --> HTML Specific and disable "Statement Completion".

Q. Why are the instance variables re-initialized on post back?
A. Since the web is by nature stateless, changes to a instance variable are lost on post back. To implement "state", you must manually write the value of the variable to the ViewState object and then read the saved value of the variable from the ViewState on post back.

// This code executes the first time only
if (!IsPostBack)
{
    view.Sort = "au_id"+ " ASC";
    ViewState["LastSortOrder"]="ASC";
    ViewState["LastSortColumn"]= "au_id";
    ViewState["LastFilter"]= "";
    DataGrid1.DataBind();
}
else // This code executes only on post back
{
    string lastSortColumn= (string)ViewState["LastSortColumn"];
    string lastSortOrder= (string)ViewState["LastSortOrder"];
    string lastFilter= (string)ViewState["LastFilter"];
    view.Sort= lastSortColumn+ " "+ lastSortOrder;
    view.RowFilter= lastFilter;
}

Comments

  • Untyped dataset

    Posted by vjero on 26 Jan 2006

    How could i do all this with untyped dataset from xml source? (no find methods etc..)
    Vjero

  • sorting in dataview

    Posted by start on 23 Nov 2005

    hi
    hey ppl i m inserting some data manually in a dataview then i m sorting that dta via dataview.sort , sorting is taking place perfectly here but when i embed this data into a word document then ...

  • Sorting ASC or DESC

    Posted by himan_dh on 10 Nov 2005

    hello
    I am converting C#.net code into vb.net code .
    Sorting ASC or DESC is not working .
    while degugging ,code work fine but i think some how dataset is not getting refreshed.
    I have com...

  • sorting ASC or DESC

    Posted by ccharneca on 30 Jun 2005

    Hi.

    I dont know if this only a problem of mine, but when I hit a sort column the DataGridSortCommand happens twice.

    Should this happen? In my case it happens and so all the code in that event do...

  • ResetPageIndex

    Posted by nczimm on 10 Nov 2004

    How do I obtain ResetPageIndex? It is unknown to my installation of .NET or at least to the libraries I am using.