Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

GridView not visible

Posted on 2008-10-12
2
Medium Priority
?
1,017 Views
Last Modified: 2012-05-05
I have a GridView control on my Web Form. I am filling the rows on Page_Load. The query is correct and showing all rows when run from SQL Server Management Studio. But when this query is executed from ASP.NET, the GridView is not visible.
protected void Page_Load(object sender, EventArgs e)
    {
        FillGrid();
    }
 
    protected void FillGrid()
    {
         SqlDataReader dr = ReUse.ReturnDR("SELECT CATEGORYNAME FROM CATEGORYMASTER ORDER BY CATEGORYNAME");
        gvCategory.DataSource = dr;
    }
 
public static class ReUse
{
    #region Return DataReader
    public static SqlDataReader ReturnDR(string sqlQuery)
    {
        OpenConnection();
        SqlCommand cmd = new SqlCommand(sqlQuery, CN);
        SqlDataReader dr = null;
 
        try
        {
            dr = cmd.ExecuteReader();
            dr.Read();
            return dr;
        }
        finally
        {
            CloseConnection();
            cmd.Dispose();
        }

Open in new window

0
Comment
Question by:rpkhare
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
Anurag Agarwal earned 150 total points
ID: 22700420
I guess after

gvCategory.DataSource = dr;

you have to call

gvCategory.DataBind();


Anurag
0
 
LVL 8

Author Closing Comment

by:rpkhare
ID: 31505550
Oh. what a shit mistake it was.
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question