student code| student.Name |Region Name|Location Name| Assets Details |
I have to display asset details on the basis of each student. There can be more than one asset details for one student, how can i use this in repeater or gridview.
Table which i have in SQL.
Student Code | student name | Asset Details
1 Ray laptop
1 Ray Bed
2 Raj Phone
2 Raj charger\
....
I want to display asset details for each unique student code like this on my page.
Student Code | student name | Asset Details
1 Ray laptop
Bed
2 Raj Phone
Charger
How do i perform the same with only one hit from sql.?
You can do the following:
Use a stored procedure to return two results set for the following queries
SELECT DISTINCT StudentCode, studentname FROM StudentInfo
SELECT StudentCode, student name, Asset Details
Create a DataSet for the results with 2 tables. You can name the first table "Student" and the second table "StudentInfo"
Create a relationship for the tables (please use the intellisense for syntax)
DataSet.Relationships.Add("RelationshipName",Table1.StudentCode,Table2.StudentCode)
Bind the GridView with the DataSet
Create a Template column for Asset Details and insert a repeater or Gridview for that column.
On the ItemDataBound
event of the GridView.
DataRowView drv = (DataRowView)e.ItemData;
Repeater.DataSource = dv.CreateChildView();