Tuesday, September 21, 2004

Top questions about Datagrid

Top questions about Datagrid

The DataGrid Web server control is a powerful tool for displaying information from a data source. It is easy to use; you can display editable data in a professional-looking grid by setting only a few properties. At the same time, the grid has a sophisticated object model that provides you with great flexibility in how you display the data.

This paper addresses some of the questions about customizing grid display that are commonly asked in newsgroups, on Web sites, and in other developer forums.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchTopQuestionsAboutASPNETDataGridServerControl.asp




Q) When I try to do an Update from my Datagrid, I keep getting the old/original values. Why?

This is caused by calling DataBind() on the grid before retrieving the updated values. The DataBind() overwrites the updates with the original values. Usually caused by having the initial DataBind() of the grid called on every Page_Load. Solution: call DataBind() only the first time the page is loaded:

Sub Page_Load(s As Object, e As EventArgs)
If Not IsPostBack Then BindGrid()
End Sub


With Best Regards,
Mitesh Mehta
Email : miteshvmehta@gmail.com
http://cc.1asphost.com/miteshvmehta/

No comments: