Solved

GridView not visible

Posted on 2008-10-12
2
1,009 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:
anuragal earned 50 total points
Comment Utility
I guess after

gvCategory.DataSource = dr;

you have to call

gvCategory.DataBind();


Anurag
0
 
LVL 8

Author Closing Comment

by:rpkhare
Comment Utility
Oh. what a shit mistake it was.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now