How to Fetch Data From Database into a gridview

I want to fetch the data from database into a gridview fulfilling certain conditions.....But the data is not getting displayed
Fdate.aspx.cs
ShowP1.aspx.cs
Sukesh ShuklaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Easwaran ParamasivamCommented:
Could you share the code of ShowP1.aspx as well? I suspect the GridView initialization part. BTW, did you debug the application to see the reader object has the expected values? If not, please debug and confirm the values are returned by the select command.
0
Sukesh ShuklaAuthor Commented:
code of ShowP1.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ShowP1.aspx.cs" Inherits="housing1.ShowP1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2">
            <Columns>
                <asp:BoundField DataField="Flat" HeaderText="Flat" SortExpression="Flat" />
                <asp:BoundField DataField="First_Name" HeaderText="First_Name" SortExpression="First_Name" />
                <asp:BoundField DataField="Middle_Name" HeaderText="Middle_Name" SortExpression="Middle_Name" />
                <asp:BoundField DataField="Last_Name" HeaderText="Last_Name" SortExpression="Last_Name" />
                <asp:BoundField DataField="Mobile_NO" HeaderText="Mobile_NO" SortExpression="Mobile_NO" />
                <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
                <asp:BoundField DataField="DOB" HeaderText="DOB" SortExpression="DOB" />
                <asp:BoundField DataField="Age" HeaderText="Age" SortExpression="Age" />
                <asp:BoundField DataField="Education" HeaderText="Education" SortExpression="Education" />
                <asp:BoundField DataField="Office_Add" HeaderText="Office_Add" SortExpression="Office_Add" />
                <asp:BoundField DataField="Native_Add" HeaderText="Native_Add" SortExpression="Native_Add" />
                <asp:BoundField DataField="PAN_Card" HeaderText="PAN_Card" SortExpression="PAN_Card" />
                <asp:BoundField DataField="Aadhar_Card" HeaderText="Aadhar_Card" SortExpression="Aadhar_Card" />
                <asp:BoundField DataField="Religion" HeaderText="Religion" SortExpression="Religion" />
                <asp:BoundField DataField="Business_Job" HeaderText="Business_Job" SortExpression="Business_Job" />
                <asp:BoundField DataField="Married_Unmarried" HeaderText="Married_Unmarried" SortExpression="Married_Unmarried" />
                <asp:BoundField DataField="No_Of_Members" HeaderText="No_Of_Members" SortExpression="No_Of_Members" />
                <asp:BoundField DataField="Joining_Date" HeaderText="Joining_Date" SortExpression="Joining_Date" />
                <asp:BoundField DataField="Leaving_Date" HeaderText="Leaving_Date" SortExpression="Leaving_Date" />
            </Columns>
            <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
            <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
            <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
            <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
            <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#FFF1D4" />
            <SortedAscendingHeaderStyle BackColor="#B95C30" />
            <SortedDescendingCellStyle BackColor="#F1E5CE" />
            <SortedDescendingHeaderStyle BackColor="#93451F" />
        </asp:GridView>
        <br />
        <br />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:HousingConnectionString %>" SelectCommand="SELECT * FROM [Ex_Primary_Member] ORDER BY [Flat]"></asp:SqlDataSource>
    
    </div>
    </form>
</body>
</html>

Open in new window

0
Sukesh ShuklaAuthor Commented:
Since i'm a beginner , could you please help me with the steps of debugging too....
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ShowP1.aspx.cs" Inherits="housing1.ShowP1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2">
            <Columns>
                <asp:BoundField DataField="Flat" HeaderText="Flat" SortExpression="Flat" />
                <asp:BoundField DataField="First_Name" HeaderText="First_Name" SortExpression="First_Name" />
                <asp:BoundField DataField="Middle_Name" HeaderText="Middle_Name" SortExpression="Middle_Name" />
                <asp:BoundField DataField="Last_Name" HeaderText="Last_Name" SortExpression="Last_Name" />
                <asp:BoundField DataField="Mobile_NO" HeaderText="Mobile_NO" SortExpression="Mobile_NO" />
                <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
                <asp:BoundField DataField="DOB" HeaderText="DOB" SortExpression="DOB" />
                <asp:BoundField DataField="Age" HeaderText="Age" SortExpression="Age" />
                <asp:BoundField DataField="Education" HeaderText="Education" SortExpression="Education" />
                <asp:BoundField DataField="Office_Add" HeaderText="Office_Add" SortExpression="Office_Add" />
                <asp:BoundField DataField="Native_Add" HeaderText="Native_Add" SortExpression="Native_Add" />
                <asp:BoundField DataField="PAN_Card" HeaderText="PAN_Card" SortExpression="PAN_Card" />
                <asp:BoundField DataField="Aadhar_Card" HeaderText="Aadhar_Card" SortExpression="Aadhar_Card" />
                <asp:BoundField DataField="Religion" HeaderText="Religion" SortExpression="Religion" />
                <asp:BoundField DataField="Business_Job" HeaderText="Business_Job" SortExpression="Business_Job" />
                <asp:BoundField DataField="Married_Unmarried" HeaderText="Married_Unmarried" SortExpression="Married_Unmarried" />
                <asp:BoundField DataField="No_Of_Members" HeaderText="No_Of_Members" SortExpression="No_Of_Members" />
                <asp:BoundField DataField="Joining_Date" HeaderText="Joining_Date" SortExpression="Joining_Date" />
                <asp:BoundField DataField="Leaving_Date" HeaderText="Leaving_Date" SortExpression="Leaving_Date" />
            </Columns>
            <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
            <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
            <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
            <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
            <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#FFF1D4" />
            <SortedAscendingHeaderStyle BackColor="#B95C30" />
            <SortedDescendingCellStyle BackColor="#F1E5CE" />
            <SortedDescendingHeaderStyle BackColor="#93451F" />
        </asp:GridView>
        <br />
        <br />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:HousingConnectionString %>" SelectCommand="SELECT * FROM [Ex_Primary_Member] ORDER BY [Flat]"></asp:SqlDataSource>
    
    </div>
    </form>
</body>
</html>

Open in new window

0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Easwaran ParamasivamCommented:
Put the breakpoint in the ShowP1.aspx.cs at the GetResults() method. Run the application. The breakpoint would be hit. Press F10 each line. Once  reader = com.ExecuteReader(); is executed, see the value of reader in quick watch window. The table should data.

Please refer any guide/google on how to debug applications. You can get better idea.
0
Sukesh ShuklaAuthor Commented:
Thank you...... Easwaran Paramasivam
0
Easwaran ParamasivamCommented:
If my comments helps could you please give points?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.