A common way to use these collections is to HTML-encode the values supplied by the user before they are stored in the data source.
Suelen darse los escenarios en donde se necesite editar distintas entidades pero haciendo uso de un único control gridview.
Rather than displaying the Hire Date field, imagine that you were required to display a seniority level based on the number of days they had been employed.
A Post Back events wipes out the Data Table and the Grid View's datasource.
The only way to maintain this data is to either save it in a Session variable or re-read it from the SQL database.
Let's look at how to accomplish exactly this with the Grid View. Data Bind() End If End Sub Dim territory Data As Data View ' this Data View will hold all of the Territories, loaded at Page_Load Sub Page_Load(By Val sender As Object, By Val e As Event Args) ' Load all of the territories into a Data View from the Sql Data Source territory Data = _ CType(territories Data Source. Empty), Data View) End Sub void employees Grid View_Row Data Bound(object sender, Grid View Row Event Args e) Data View territory Data; // this Data View will hold all of the Territories, loaded at Page_Load void Page_Load(object sender, Event Args e) The data is loaded in the Page_Load event handler by calling the territories Data Source Sql Data Source's Select() method.
The Northwind database's Employees table participates in a one-to-many relationship with the Terroritories table—each employee is assigned an arbitrary number of territories. This returns a Data View containing the data encapsulated by the Sql Data Source control. NET page's declarative syntax to see the details for the territories Data Source Sql Data Source.) The Row Data Bound event handler is fired for each row, including non-Data Rows, such as the Header and Footer.