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
Solved

GridView not visible

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C#, asp.net MVC, sql server, LINQ 3 37
Javascript to set controls visibility 5 48
asp Google Map 2 31
SSRS Deployment problem 5 65
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

861 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