Gridview templatefield not updating
This filtered Data View is then bound to the Bulleted List.
The Row Data Bound and Page_Load Event Handlers (Visual Basic) Sub employees Grid View_Row Data Bound(By Val sender As Object, _ By Val e As Grid View Row Event Args) ' For each Data Row in the Grid View, ' programmatically access the Bulleted List, filter ' the Data View based on the Grid View row's ' Employee ID value and bind the filtered Data View ' to the Bulleted List If e.
We can display the employee's associated territories in a Bulleted List by adding a Template Field to the Grid View and then adding a Bulleted List to the Template Field. Since we are only interested in dealing with Data Rows, an If statement is used to ensure that we're dealing with a Data Row.
The resulting declarative syntax for the Data Grid would look like: Note that the Bulleted List's Data Text Field property has been set to Territory Description, which is the field name in the Northwind's Territories table that provides a description of the territory. In that case, the Bulleted List is programmatically referenced and its Data Source property is set to the filtered territory Data Data View.
All of the necessary functionality is encapsulated within the Grid View.
Hi zassadgh, According to your description, I found you call the Sql Data Source1.
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.
This method must accept an integer input—the number of days the employee has been employed—and must return a string—the seniority title. For example, if you are displaying entities from a database in a Grid View that participate as the "one" in a one-to-many relationship you might want to also display the related "many" records for each row.
One way to accomplish this would to use a Template Field with a Bulleted List control embedded within it.