D
Dan
Hi,
i defined a gridview in aspx file and i try to connect it to a datasource in
code-behind (vb.net).
i know there are records (tested with response.write).
The problem is that the gridview remains invisible because no records come
into it.
Here is the code:
Thanks
Dan
code in aspx file
----------------
<asp:GridView ID="GridView1" runat="server" >
</asp:GridView>
code-behind
-------------
Dim bf As New BoundField
Dim dtreader As SqlDataReader
.....
.....
comd.CommandText = "select email from email"
dtreader = comd.ExecuteReader
If dtreader.HasRows Then
While dtreader.Read()
dtreader.GetString(0)
'tested with response.write
End While
End If
bf.DataField = "email"
bf.HeaderText = "email"
GridView1.Columns.Add(bf)
GridView1.DataSource = dtreader
GridView1.DataBind()
i defined a gridview in aspx file and i try to connect it to a datasource in
code-behind (vb.net).
i know there are records (tested with response.write).
The problem is that the gridview remains invisible because no records come
into it.
Here is the code:
Thanks
Dan
code in aspx file
----------------
<asp:GridView ID="GridView1" runat="server" >
</asp:GridView>
code-behind
-------------
Dim bf As New BoundField
Dim dtreader As SqlDataReader
.....
.....
comd.CommandText = "select email from email"
dtreader = comd.ExecuteReader
If dtreader.HasRows Then
While dtreader.Read()
dtreader.GetString(0)
'tested with response.write
End While
End If
bf.DataField = "email"
bf.HeaderText = "email"
GridView1.Columns.Add(bf)
GridView1.DataSource = dtreader
GridView1.DataBind()