我有一个 ASP.NET GridView,它没有填充来自 VB.NET 填充的新行。我正在使用的代码的最新版本如下:
Protected Sub uGV(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnQuery.Click
Dim rFm As DateTime = DateTime.Parse(calFrom.SelectedDate.Date.ToString)
Dim rTo As DateTime = DateTime.Parse(calTo.SelectedDate.Date.ToString)
Dim oleUpConnString As String = ConfigurationManager.ConnectionStrings("OLEDBConnectionStringtoSQL").ConnectionString
Dim oleUpConn As New OleDbConnection()
oleUpConn.ConnectionString = oleUpConnString
oleUpConn.Open()
Dim vUp As New OleDbDataAdapter()
Dim upCmd As String = "SELECT * FROM mail WHERE (date BETWEEN '07/02/2013' AND '07/04/2013')"
Dim dsUp As New DataSet()
Dim dt As New DataTable("Table1")
Dim upCmdEx As New OleDbCommand(upCmd, oleUpConn)
With upCmdEx.Parameters
.AddWithValue("?", rFm)
.AddWithValue("?", rTo)
End With
Try
vUp.SelectCommand = upCmdEx
Catch ex As Exception
MsgBox("The select command failed")
End Try
Try
Me.GridView2.DataSource = dsUp.Tables(0)
vUp.Fill(dsUp)
Catch ex As Exception
MsgBox("Filling the dataset failed")
End Try
Me.GridView2.DataSource = dsUp
'Me.GridView2.DataBind()
oleUpConn.Close()
End Sub
我花了几个小时没有解决这个问题,所以如果有人能确定我错过了什么,将不胜感激。
编辑 - GridView 编码如下:
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="True"
BackColor="White" CaptionAlign="Top"
CellPadding="4" ForeColor="#333333"
GridLines="None" Caption="Surveys Completed">
<RowStyle BackColor="#EFF3FB" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>