Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I need to populate a gridview upon user login. I have written a stored procedure for populating that gridview using login credentials... my stored procedure is working ... I'm able to get the output in SQL Server but once I use login id and password and logs in gridview isn't getting populated... please help me out..

This is my codes and stored procedure

Stored procedure:
ALTER PROCEDURE [dbo].[GetManager]

@EmpName nvarchar(50)

AS

Select TaskName, DueDate, Description, AssignBy, AssignTo, Status, PercentageComplete, TaskID

From dbo.Task, dbo.EmployeeData

Where AssignTo in (Select EmpName From EmployeeData Where Manager = 'RaghavendraS')

And AssignBy in (Select EmpName From EmployeeData Where Manager = 'RaghavendraS')

And EmpName = @EmpName;


I'm using 3 layered architecture.. wich has DTO,DAL and business layer.. I'm calling data source through these layers.

Backend code

DAL :
public DataSet GetManager(MTMSDTO M)
{
DBAccess db = new DBAccess();
SqlParameter objParam = new SqlParameter("@EmpName", M.EmpName);
objParam.Direction = ParameterDirection.Input;
objParam.Size = 50;

db.Parameters.Add(objParam);
return db.ExecuteDataSet("GetManager");
}

BusinessLayer :

public DataSet GetManager(MTMSDTO M)
{
MTMSAccess obj = new MTMSAccess();
return obj.GetManager(M);
}

Gridview calling function using stored procedure:


protected void GrdManager()
{
MTMSDTO objc = new MTMSDTO();
{
objc.EmpName = Convert.ToString(Session["EmpName"]);
DataSet GrdMA = obj.GetManager(objc);
DataView GrdMan = new DataView();
GrdMan.Table = GrdMA.Tables[0];
GridViewTTlist.DataSource = GrdMan;
GridViewTTlist.DataBind();
}
}


aspx code of grid view

ASP.NET
<div  class="Container" style="width: 99%; height: 370px;">
                                                                                                        <asp:GridView ID="GridViewTTlist" runat="server" AllowSorting="True" 
                                                                                                        AutoGenerateColumns="false" BackColor="White" BorderColor="#0061C1" 
                                                                                                        BorderStyle="None" CaptionAlign="Bottom" EmptyDataText="No Records Found" 
                                                                                                        Font-Names="Verdana" Font-Size="X-Small" ForeColor="#0061C1" 
                                                                                                        Height="109px" OnRowDataBound="GridViewTTlist_RowDataBound" 
                                                                                                        ShowFooter="True" ShowHeaderWhenEmpty="True" Width="99%" 
                                                                                                                                                            onselectedindexchanged="GridViewTTlist_SelectedIndexChanged" >
                                                                                                    
                                                                                                        <Columns>
                                                                                                       <asp:BoundField DataField="TaskID" HeaderText="SL No" Visible="true" 
                                                                                                        ReadOnly="false" >
                                                                                                                                                                                    <FooterStyle BackColor="#0061C1" />
                                                                                                                                                                                    <HeaderStyle BackColor="#0061C1"  
                                                                                                                                                                                        HorizontalAlign="Center" VerticalAlign="Middle" />
                                                                                                                                                                                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                                                                                                                                                                    </asp:BoundField>
                                                                                                                                                                                    <asp:TemplateField HeaderText="Task Name">
                                                                                                                                                                                    <ItemTemplate>
                                                                                                                                                                                        <asp:Label ID="TaskName" runat="server"  
                                                                                                                                                                                            Font-Names="Verdana" Font-Size="X-Small" Height="24px" 
                                                                                                                                                                                            Text='<%# Eval("TaskName")%>' Width="70px"></asp:Label>
                                                                                                                                                                                    </ItemTemplate>
                                                                                                                                                                                    <FooterStyle BackColor="#0061C1" />
                                                                                                                                                                                    <HeaderStyle BackColor="#0061C1" ForeColor="White" />
                                                                                                                                                                                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                                                                                                                                                                </asp:TemplateField>
                                                                                                                                                                                
                                                                                                                                                                                <asp:TemplateField HeaderText="Due Date">
                                                                                                                                                                                    <ItemTemplate>
                                                                                                                                                                                        <asp:Label ID="DueDate" runat="server"  
                                                                                                                                                                                            Font-Names="Verdana" Font-Size="X-Small" 
                                                                                                                                                                                            Height="20px" Width="70px" Text='<%# Eval("DueDate","{0:dd/MM/yyyy}")%>' DataFormatString="{0:dd/MM/yyyy}"></asp:Label>
                                                                                                                                                                                    </ItemTemplate>
                                                                                                                                                                                    <FooterStyle BackColor="#0061C1" />
                                                                                                                                                                                    <HeaderStyle BackColor="#0061C1" ForeColor="White" />
                                                                                                                                                                                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                                                                                                                                                                </asp:TemplateField>
                                                                                                                                                                                <asp:TemplateField HeaderText="Description">
                                                                                                                                                                                    <ItemTemplate>
                                                                                                                                                                                        <asp:Label ID="Description" runat="server"  
                                                                                                                                                                                             Font-Names="Verdana" Font-Size="X-Small" Height="20px" Width="90px" Text='<%# Eval("Description")%>'></asp:Label>
                                                                                                                                                                                    </ItemTemplate>
                                                                                                                                                                                    <FooterStyle BackColor="#0061C1" />
                                                                                                                                                                                    <HeaderStyle BackColor="#0061C1" ForeColor="White" />
                                                                                                                                                                                    <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
                                                                                                                                                                                </asp:TemplateField>
                                                                                                                                                                                <asp:TemplateField HeaderText="Assign By">
                                                                                                                                                                                    <ItemTemplate>
                                                                                                                                                                                        <asp:Label ID="AssignBy" runat="server"  
                                                                                                                                                                                        Font-Names="Verdana" Font-Size="X-Small" Height="20px" Width="60px" Text='<%# Eval("AssignBy")%>'></asp:Label>
                                                                                                                                                                                    </ItemTemplate>
                                                                                                                                                                                    <FooterStyle BackColor="#0061C1" />
                                                                                                                                                                                    <HeaderStyle BackColor="#0061C1" ForeColor="White" />
                                                                                                                                                                                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                                                                                                                                                                </asp:TemplateField>
                                                                                                                                                                                 <asp:TemplateField HeaderText="Assign To">
                                                                                                                                                                                    <ItemTemplate>
                                                                                                                                                                                        <asp:Label ID="AssignTo" runat="server"  
                                                                                                                                                                                        Font-Names="Verdana" Font-Size="X-Small" Height="20px" Width="90px" Text='<%# Eval("AssignTo")%>'></asp:Label>
                                                                                                                                                                                    </ItemTemplate>
                                                                                                                                                                                    <FooterStyle BackColor="#0061C1" />
                                                                                                                                                                                    <HeaderStyle BackColor="#0061C1" ForeColor="White" />
                                                                                                                                                                                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                                                                                                                                                                </asp:TemplateField>
                                                                                                                                                                                <asp:TemplateField HeaderText="Status">
                                                                                                                                                                                    <ItemTemplate>
                                                                                                                                                                                        <asp:Label ID="Status" runat="server"  
                                                                                                                                                                                         Font-Names="Verdana" Font-Size="X-Small" Height="20px" Width="90px" Text='<%# Eval("Status")%>'></asp:Label>
                                                                                                                                                                                    </ItemTemplate>
                                                                                                                                                                                    <FooterStyle BackColor="#0061C1" />
                                                                                                                                                                                    <HeaderStyle BackColor="#0061C1" ForeColor="White" />
                                                                                                                                                                                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                                                                                                                                                                </asp:TemplateField>
                                                                                                                                                                                <asp:TemplateField HeaderText="% Complete">
                                                                                                                                                                                   <ItemTemplate>
                                                                                                                                                                                        <asp:Label ID="PercentageComplete" runat="server"  
                                                                                                                                                                                            Font-Names="Verdana" Font-Size="X-Small"  
                                                                                                                                                                                            Height="20px" Width="68px" Text='<%# Eval("PercentageComplete")%>'></asp:Label>
                                                                                                                                                                                   </ItemTemplate>
                                                                                                                                                                                    <FooterStyle BackColor="#0061C1" />
                                                                                                                                                                                    <HeaderStyle BackColor="#0061C1" ForeColor="White" />
                                                                                                                                                                                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                                                                                                                                                                </asp:TemplateField>
                                                                                                                                                                            <asp:TemplateField HeaderText="View Details">
                                                                                                                                                                                    <ItemTemplate>
                                                                                                                                                                                        <asp:HyperLink ID="ViewDetails" runat="server" Font-Names="Verdana" Font-Size="X-Small" Height="24px" 
                                                                                                                                                                                             Width="70px" ForeColor="#0061C1" Text="ViewDetails"
                                                                                                                                                                                              NavigateUrl="Reports.aspx" DataNavigateUrlFields="TaskID" DataNavigateUrlFormatString="Reports.aspx?TaskID={0}">View</asp:HyperLink>
                                                                                                                                                                                    </ItemTemplate>
                                                                                                                
                                                                                                                                                                                    <FooterStyle BackColor="#0061C1" />
                                                                                                                                                                                    <HeaderStyle BackColor="#0061C1" ForeColor="White" />
                                                                                                                                                                                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                                                                                                                                                                </asp:TemplateField>
                                                                                                                                                                                                </Columns>
                                                                                                                                                                                            </asp:GridView>
                                                                                                                                                                                          <div>


text/css file
ASP.NET
<asp:Content ID="Content2" runat="server" contentplaceholderid="head">
    <style type="text/css">
       .Container
        {
        overflow: auto;
        }
        .ButtonClass
        {
         cursor  : pointer;
        }
        .style18
        {
            height: 23px;
        }
        .style26
        {
            width: 1000px;
            height: 89px;
        }
        .style40
        {
            color: #0061C1;
        }
        .style50
        {
            width: 14px;
            height: 425px;
        }
        .style51
        {
            width: 608px;
            height: 425px;
        }
        .style52
        {
            height: 425px;
            width: 18px;
        }
        .style86
        {
            height: 89px;
        }
        .style87
        {
            width: 82px;
        }
        .style89
        {
            width: 1000px;
            height: 69px;
        }
        .style91
        {
            width: 82px;
            height: 49px;
        }
        .style115
        {
            width: 27px;
        }
        .style118
        {
            width: 147px;
            font-weight: 700;
            color: #0061C1;
            font-family: Verdana;
            font-size: small;
            height: 46px;
            text-align: left;
        }
        .style121
        {
            width: 257px;
            font-weight: 700;
            color: #0061C1;
            font-family: Verdana;
            font-size: small;
            height: 46px;
            text-align: left;
        }
        .style122
        {
            height: 49px;
        }
        .style123
        {
            width: 27px;
            height: 23px;
        }
        .style124
        {
            height: 69px;
        }
        .style125
        {
            width: 82px;
            height: 1px;
        }
        .style126
        {
            height: 1px;
        }
        .style127
        {
            width: 27px;
            height: 68px;
        }
        .style128
        {
            height: 68px;
        }
        </style>
Posted
Updated 2-Jul-13 20:05pm
v8
Comments
[no name] 28-Jun-13 2:43am    
can you show me the method db.ExecuteDataSet(string s)?
s_rao88 28-Jun-13 2:51am    
public DataSet ExecuteDataSet()
{
SqlDataAdapter da = null;
DataSet ds = null;
try
{
da = new SqlDataAdapter();
da.SelectCommand = (SqlCommand)cmd;
ds = new DataSet();
da.Fill(ds);
}
catch (Exception ex)
{
throw;
}

return ds;
}


public DataSet ExecuteDataSet(string commandtext)
{
DataSet ds = null;
try
{
cmd.CommandText = commandtext;
ds = this.ExecuteDataSet();
}
catch (Exception ex)
{
throw;
}

return ds;
}

this is wat u have asked for
[no name] 28-Jun-13 3:06am    
Dear Mahesh.
connection is missing while you are putting your data in SqlDataAdapter.
No doubt your code is professional.But it could be minor mistake.

hope it will help.
s_rao88 28-Jun-13 3:14am    
public DBAccess()
{
ConnectionStringSettings objConnectionStringSettings = ConfigurationManager.ConnectionStrings["****"];
strConnectionString = objConnectionStringSettings.ConnectionString;
SqlConnection cnn = new SqlConnection();
cnn.ConnectionString = strConnectionString;
cmd.Connection = cnn;
cmd.CommandType = CommandType.StoredProcedure;
}

what is this ?
s_rao88 28-Jun-13 6:21am    
"public DataSet ExecuteDataSet(string commandtext)" here it says abt logged in user.. it dsnt take GetManager function... however data is coming coz im extracting loin details frm database only...

1 solution

Hi Friend,
As you are saying that you are getting 9 records in DataView but still you are not getting records on your GridView then i think you are doing any mistake on Design page in HTML i think there is any css on gridview to hide Gridview, if possible then show your HTML Design Page for correct answer and check your css and properties at your end.
 
Share this answer
 
v2
Comments
s_rao88 3-Jul-13 2:07am    
please go through my post.. i have updated my post with aspx code and my text/css file.... i dnt hav any css file bt i got container and button class.... i dnt thnk those 2 arent hiding my grid view
s_rao88 4-Jul-13 6:14am    
thnks guys i got d grid view displayed atlast... nt sure wat d prblm was .. but i removed my panel n tried displayng it and i got d result... n i checked the panel properties its nt hidden too...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900