我尝试使用Response.Write添加AccessDataSource和GridView逻辑。 但它不起作用。为什么呢?
我在谷歌搜索,但发现的解释很少。请问怎么用?
Sub doInquiry(ByVal sender As Object, _
ByVal e As EventArgs)
Dim _div_1 As String = "<div style='position:absolute;top:180px;left:20px;width:1800px;'>"
Dim _datasource As String = "<asp:AccessDataSource ID=""AccessDataSource1"" runat=""server"" DataFile=""~/App_Data/Northwind.MDB"" SelectCommand=""Select * FROM [Categories]""></asp:AccessDataSource>"
Dim _gridview_1 As String = "<asp:GridView ID=""GridView1"" runat=""server"" AutoGenerateColumns=""False"" DataKeyNames=""CategoryID"" DataSourceID=""AccessDataSource1"" EnableModelValidation=""True"">"
Dim _gridview_2 As String = " </asp:GridView>"
Dim _tag_col_1 As String = "<Columns>"
Dim _tag_col_2 As String = "</Columns>"
Dim _field_1 As String = "<asp:BoundField DataField=""CategoryID"" HeaderText=""CategoryID"" InsertVisible=""False"" ReadOnly=""True"" SortExpression=""CategoryID"" />"
Dim _field_2 As String = "<asp:BoundField DataField=""CategoryName"" HeaderText=""CategoryName"" SortExpression=""CategoryName"" />"
Dim _field_3 As String = "<asp:BoundField DataField=""Description"" HeaderText=""Description"" SortExpression=""Description"" />"
Dim _div_2 As String = "</div>"
Dim combine As String = _div_1 & _datasource & _
_gridview_1 & _tag_col_1 & _
_field_1 & _field_2 & _field_3 & _
_tag_col_2 & _gridview_2 & _div_2
Response.Write(combine)
End Sub