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 HussainPosted Jun 28, 2013, 8:06 AM
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
Suraj RaoPosted Jun 28, 2013, 7:25 AM
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();
}
}
Suraj RaoPosted Jun 28, 2013, 7:18 AM
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
Iftikar HussainPosted Jun 28, 2013, 7:17 AM
Regards,
Iftikar
Suraj RaoPosted Jun 28, 2013, 7:14 AM
Iftikar HussainPosted Jun 28, 2013, 6:58 AM
Regards,
Iftikar
Suraj RaoPosted Jun 28, 2013, 6:50 AM
Iftikar HussainPosted Jun 28, 2013, 6:47 AM
Regards,
Iftikar
Suraj RaoPosted Jun 28, 2013, 6:43 AM
Suraj RaoPosted Jun 28, 2013, 6:41 AM
Iftikar HussainPosted Jun 28, 2013, 6:38 AM
Regards,
Iftikar
Suraj RaoPosted Jun 28, 2013, 6:16 AM
Iftikar HussainPosted Jun 28, 2013, 5:44 AM
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 RaoPosted Jun 28, 2013, 5:39 AM
Iftikar HussainPosted Jun 28, 2013, 5:24 AM
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 RaoPosted Jun 28, 2013, 5:16 AM
Iftikar HussainPosted Jun 28, 2013, 4:21 AM
Regards,
Iftikar
Suraj RaoPosted Jun 28, 2013, 3:49 AM
Iftikar HussainPosted Jun 28, 2013, 3:09 AM
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 RaoPosted Jun 28, 2013, 3:04 AM
Iftikar HussainPosted Jun 28, 2013, 3:01 AM
Put the break point on objc.EmpName = Convert.ToString(Session["EmpName"]); andd check weather your getting the correct emp name or not.
Regards,
Iftikar