Solved

GridView not visible

Posted on 2008-10-12
2
1,014 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 50 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

623 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