Library tutorials & articles
Web Forms DataGrid and DataSet Programming
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;
}
Related articles
Related discussion
-
Chart insertation in a windows form...
by pdhanik (1 replies)
-
Writing Plugin-Based Applications
by haneen (12 replies)
-
filter dataview on datagrid in datalist
by janetb (0 replies)
-
ASP .NET Web Service Error Message ,"Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'."
by salil15august (1 replies)
-
hey developers out there
by pitsophera (0 replies)
Related podcasts
-
Writing FaceBook Applications with .NET - Interview with Mel Sampat, author of Outsync
In this episode, Scott talks with Mel Sampat, a Program Manager at Microsoft who's written OutSync, an application that syncs faces between Outlook, Facebook, and indirectly Windows SmartPhones. They chat about what it takes to write your own FaceBook application using ASP.NET or WinForms.
Events coming up
-
Mar
15
DevWeek 2010
London, United Kingdom
DevWeek is Europe’s leading independent conference for software developers, database professionals and IT architects, and features expert speakers on a wide range of topics, including .NET 4.0, Silverlight 3, WCF 4, Visual Studio 2010, REST, Windows Workflow 4, Thread Synchronization, ASP.NET 4.0, SQL Server 2008 R2, LINQ, Unit Testing, CLR & C# 4.0, .NET Patterns, WPF 4, F#, Windows Azure, ADO.NET, Entity Framework, Debugging, T-SQL Tips & Tricks, and more.
Vjero
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 i found that data is not in sorted order as this supposed to be but it is in order in which it had typed...........so guys if u have have any solution of this problem then plz mail me at aman_105@rediffmail.com
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 commented these line 'view.RowFilter = lastFilter' .Is it require for sorting
Execpt that everything is same
please help me out .
Thanks
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 doesnt work properly...
Could some help me out on this one?
TIA,
C.C.
Jeff,
Thanks a bunch! I am new to ASP.NET programming and it was having a devil of a time getting my datagrid to sort -- your example provided the one missing link: the DataSource property should have been set to the view and not the dataset! Tanx again.
--Babak
This thread is for discussions of Web Forms DataGrid and DataSet Programming.