Last post Nov 10, 2010 12:19 PM by silverlight.shailendra
Nov 06, 2010 02:12 AM|Silverlight.Shailendra|LINK
I have a GridView where I am displaying the students List who ware absent for "ASP.Net Class" If Teacher 1 login then it is displying all the records who ware absent and same for remaining teachers. I want to display those records where TecherId
I wrote query like this :
Select StudName FROM Class where Status LIKE 'ABSENT' AND Teacher Id =?
But every teachers(User) are getting everyone's data....
anyone know this?
I am using AccessDataSource and displying in GridView....
Nov 06, 2010 06:02 AM|adeelehsan|LINK
How are you getting the teacher id? Are you storing the teacher id in the session when the teacher logs in ? OR you are asking the teacher to enter manually.
Please explain more and post your code as well along with the table structure.
Nov 06, 2010 06:39 AM|Silverlight.Shailendra|LINK
Actually, this is the FK on aspnet_Users : UserId. It is normal
TeacherId Class StudId Status
101 ASP.NET 11 Present
101 ASP.NET 12 ABSENT
102 CPP 12 ABSENT
102 C 11 PRESENT
101 MATHS 11 PRESENT
here, when Teacher 101 logs in my system welcome him but it shows 101 as well as 102's data
I also wrote GridView's_selecting method() like this :
MembershipUser currentUser = Membership.GetUser();
int UserId = (int)currentUser.ProviderUserKey;
e.Command.Parameters["?"].Value = UserId;
<asp:AccessDataSource ID="srcCallBackReport" runat="server"
SelectCommand="SELECT TeacherID, Subject, RollNo, Date, Status FROM CLASS WHERE (Status LIKE 'Present) AND (TeacherId= ?)"
<asp:Parameter Name="?" />
Nov 10, 2010 03:01 AM|Wencui Qian - MSFT|LINK
Please try to define the parameter like this:
Then, you can set the parameter name as "TeacherId". Thanks.
Nov 10, 2010 12:19 PM|Silverlight.Shailendra|LINK
Thanks!!!! worked.... I wrote the query like this: select ....................... where TeacherId = ? PLUS i wrote this on AccessDataSource's Seleting method() MembershipUser currentUser = Membership.GetUser(); int ID = (int)currentUser.ProviderUserKey;
e.Command.Parameters["TeacherId"].Value = ID; this is most important. Because when user logs in It checks which user and depending the user it will the KEY and stored it ID.... and then only genrates the data... Thanks again for timely help