Answered by:
GridView Not visible

Question
-
User-2024981698 posted
Sir,
I am running an asp.net application in which I am using MsAccess 2003 with VB.net vs2010
The Problem is that code is running without error but the problem is that the gridview is not visible . Pl. guide
I am using 2 methods
Imports System.Data Imports System.Data.SqlClient Imports System.Data.Sql Imports System.Data.OleDb Partial Class Audit_test Inherits System.Web.UI.Page Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click 'Dim strprovider As string = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Employees.mdb"; Dim strprovider As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\Database1.mdb;Jet OLEDB:Database Password=MyDbPassword;" Dim strsql As String = "SELECT * FROM table1" Dim con As New OleDbConnection(strprovider) Dim cmd As New OleDbCommand(strsql, con) con.Open() cmd.CommandType = CommandType.Text Dim da As New OleDbDataAdapter(cmd) Dim tbl1 As New DataTable() da.Fill(tbl1) GridView1.DataSource = tbl1 End Sub End Class
<%@ Page Title="" Language="VB" MasterPageFile="~/management/MasterPage.master" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="Audit_test" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <asp:GridView ID="GridView1" runat="server"> </asp:GridView> <p> <asp:Button ID="Button1" runat="server" Text="Button" /> </p> </asp:Content>
Table is
Table1 ID name ex 1 A 1 2 B 2 3 C 3 4 D 4 5 E 5 6 F 6 7 G 7 8 H 8 9 I 9 10 J 10 Pl. guide
Wednesday, June 1, 2016 4:22 AM
Answers
-
User1724605321 posted
Hi bhushan98 ,
Please try to bind the gridview with GridView.DataBind Method :
GridView1.DataSource = tbl1 GridView1.DataBind()
Best Regards,
Nan Yu
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, June 1, 2016 6:05 AM
All replies
-
User1724605321 posted
Hi bhushan98 ,
Please try to bind the gridview with GridView.DataBind Method :
GridView1.DataSource = tbl1 GridView1.DataBind()
Best Regards,
Nan Yu
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, June 1, 2016 6:05 AM -
User-826336654 posted
Hi,
After this line
GridView1.DataSource = tbl1
Add the following line,
GridView1.DataBind()
Regards,
Thursday, June 2, 2016 10:41 AM -
User768703680 posted
Hi,
Use the below mentioned code
GridView1.DataBind();
Friday, June 3, 2016 12:18 PM -
User-1377768212 posted
Hi,
GridView1.DataSource = tbl1You should bind Gridview after above table initialisation in Grid.
GridView1.DataBind()
Monday, June 6, 2016 6:47 AM