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
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();
}
}
here is aspx code for grid view
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" OnRowCreated="GridViewTTlist_RowCreated" >
Text='<%# Eval("TaskName")%>' Width="70px">
Height="20px" Width="70px" Text='<%# Eval("DueDate","{0:dd/MM/yyyy}")%>' DataFormatString="{0:dd/MM/yyyy}">
Height="20px" Width="68px" Text='<%# Eval("PercentageComplete")%>'>
Text="View" Width="70px" NavigateUrl="Reports.aspx" DataNavigateUrlFields="TaskID" DataNavigateUrlFormatString="Reports.aspx?TaskID={0}" >View
snapshot of rid views. 1st is of my tasks .. i hav written query like the employee who logs in and who has been assigned task can only view the grid and 2nd snapsht is for d user who assigns d task and the 3 rd snap is of manager... alternatively wen each user logs in he/she wnt b able to view othr than their respective grid view.....




Iftikar HussainRank #423 · 5.9K reputationPosted Jun 27, 2013, 11:01 PM EDT
Put the break point on objc.EmpName = Convert.ToString(Session["EmpName"]); andd check weather your getting the correct emp name or not.
Regards,
Iftikar
Suraj Rao35 reputationPosted Jun 27, 2013, 11:04 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jun 27, 2013, 11:09 PM EDT
If you are getting the name and by using the name if you are getting the result directly by executing the SP, then you need to modify the below code
protected void GrdManager()
{
MTMSDTO objc = new MTMSDTO();
{
objc.EmpName = Convert.ToString(Session["EmpName"]);
DataSet GrdMA = obj.GetManager(objc);
GridViewTTlist.DataSource = GrdMA ;
GridViewTTlist.DataBind();
}
}
Regards,
Iftikar
Suraj Rao35 reputationPosted Jun 27, 2013, 11:49 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jun 28, 2013, 12:21 AM EDT
Regards,
Iftikar
Suraj Rao35 reputationPosted Jun 28, 2013, 1:16 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jun 28, 2013, 1:24 AM EDT
protected void GrdManager()
{
MTMSDTO objc = new MTMSDTO();
{
objc.EmpName = Convert.ToString(Session["EmpName"]);
DataSet GrdMA = obj.GetManager(objc);
var count=GrdMA.Tables[0].Rows.Count;
GridViewTTlist.DataSource = GrdMA ;
GridViewTTlist.DataBind();
}
}
Regards,
Iftikar
Suraj Rao35 reputationPosted Jun 28, 2013, 1:39 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jun 28, 2013, 1:44 AM EDT
protected void GrdManager()
{
MTMSDTO objc = new MTMSDTO();
{
objc.EmpName = Convert.ToString(Session["EmpName"]);
DataSet GrdMA = obj.GetManager(objc);
GridViewTTlist.DataSource = GrdMA.Tables[0];
GridViewTTlist.DataBind();
}
}
Regards,
Iftikar
Suraj Rao35 reputationPosted Jun 28, 2013, 2:16 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jun 28, 2013, 2:38 AM EDT
Regards,
Iftikar
Suraj Rao35 reputationPosted Jun 28, 2013, 2:41 AM EDT
Suraj Rao35 reputationPosted Jun 28, 2013, 2:43 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jun 28, 2013, 2:47 AM EDT
Regards,
Iftikar
Suraj Rao35 reputationPosted Jun 28, 2013, 2:50 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jun 28, 2013, 2:58 AM EDT
Regards,
Iftikar
Suraj Rao35 reputationPosted Jun 28, 2013, 3:14 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jun 28, 2013, 3:17 AM EDT
Regards,
Iftikar
Suraj Rao35 reputationPosted Jun 28, 2013, 3:18 AM EDT
and othr 2 grid views r displayn grid in output dependin on the login id f othr user .. i can post d snap for tht too if needed
Suraj Rao35 reputationPosted Jun 28, 2013, 3:25 AM EDT
Its thr in d post already... im callin i thru page load event...
protected void Page_Load(object sender, EventArgs e)
{
MTMSDTO objc = new MTMSDTO();
if (!IsPostBack)
protected void GrdManager(){
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();
}
}
Iftikar HussainRank #423 · 5.9K reputationPosted Jun 28, 2013, 4:06 AM EDT
I think you need to modify your SP as shown below
ALTER PROCEDURE [dbo].[GetManager]
@EmpName nvarchar(50)
AS
Select TaskName, DueDate, Description, AssignBy, AssignTo, Status, PercentageComplete
From dbo.Task, dbo.EmployeeData
Where (AssignTo in (Select EmpName From EmployeeData Where Manager = 'RaghavendraS')
or AssignBy in (Select EmpName From EmployeeData Where Manager = 'RaghavendraS'))
And EmpName = @EmpName;
Regards,
Iftikar