Questions about data binding in nested data controls in VB.NET
Lanfan [original]
Nested data controls in ASP.NET, such as REPEATER, DATALIST, DATAGRID, and the like. In the nested data control, the form of the parent table and the sub-table is usually used to bind the parent table data to the outermost data control, and the sub-table data is bound to the inner data control. There are many discussions on the online data binding issue, but there are many people with C #, many people have encountered some problems in VB.NET.
I use a relatively simple Repeater nested Repeater as an example, where I borrow the example of KWKLOVER in "ASP.NET's Hierarchical Data Display Technology". The key statement in the data binding is in the following form:
itemtemplate> ask: review>
We convert this sentence to VB is:
itemtemplate> < / ASP: REPEATER>
The error that will appear when compiled "DataBinder.eval:" System.Data.DATAROW "Properties of Name LNAME" has been repeatedly tried, and two methods to solve this problem:
First, KWKLOVER is used in "ASP.NET's Hierarchical Data Display Technology", using the CreateChildView method: Complete example is the Import System.Data Import System.Data.sqlClient Dim Objconn AS New SqlConnection ("Data Source = localhost; Database = Pubs; userid = sa; password = sa ") objConn.Open () dim strSql as string =" Select * from jobs; Select * from employee "dim objAdapter as new SqlDataAdapter (strSql, objConn) dim objDs as new DataSet ( ) Objadapter.fill (objds) Objconn.close () Set the name of the two tables objds.tables (1) .talbename = "jobs" objds.tables (0) .tablename = "Employee" 'for these two tables Add relationship Dim Parent as datacolumn = objds.tables ("jobs"). Column ("job_id") Dim Child as datacolumn = objds.tables ("Employee"). Columns ("job_id") objds.relations.add ("RELATIONNAME ", PARENT, Child) data bind to PARENTREPEATER: PARENTREPEATER.DASOURCE = Objds.tables (" jobs "). DefaultView ParentRepeater.Database is added to the following code in HTML:
Second, the <% # DataBinder.eval (Container.DataItem, "LNAME")%> is changed to <% # DataBinder.eval (contact ")")%> ie: