Click here to Skip to main content
15,173,818 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
    public void ProcessRequest (HttpContext context) {

      string RoleID = context.Session["RoleID"].ToString();
      string CompanyID = context.Session["CompanyID"].ToString();

     DataTable dt = GetData(RoleID,CompanyID);

      string json = COnvertDTtoJSON(dt); //dt Contain ProjectID,ProjectName,....

    context.Response.ContentType = "text/plain";

and now in the aspx page i call this handler to get the data and insert into the div, now I have another button(check latest) in this button i want to get the latest info but not that which is already present in div
any idea how to do it.
Do you have any unique id column in your datatable?
agha_ali22 7-Aug-12 0:18am

In table add column Insertdate datetime.
This will contain when data is inserted.

In page take hidden field. Store datetime value while calling handler for first button.

Now while calling handler when you want latest data send querystring Lastdate & its value should be hidden field value.
in handler change this
if(context.Request.QueryString["Lastdate"] != null)
DataTable dt = GetData(RoleID,CompanyID);
string Lastdate= context.Request.QueryString["Lastdate"]Tostring();
//you will get latest record here
DataTable dt= GetData(RoleID,CompanyID,Convert.ToDateTime(Lastdate));

Create method to get latest record.

public void GetData(string RoleID,string CompanyID, DateTime Lastdate)
// pass this Lastdate to get get record (Insertdate >Lastdate )
Then before converting DT to JSON, get the unique values from your datatable using LINQ.
If you provide your GetData method means i could help you in coding.
agha_ali22 7-Aug-12 1:04am
GetData just calls a stored procedure and return DT e.g
my question is first i get this data

and then in checklatest
now i only want '4' data i can pass the querystring when i call the .ashx and remove those from the datatable
Is the projectId column is Identity field or running ID in your database?.
agha_ali22 7-Aug-12 5:17am
Identity field
Then pass the latest/last id from your content as a parameter to SP and select the values in where class as greater than the parameter you passed.
agha_ali22 7-Aug-12 10:02am
i cannot do it because in the table there is another columns (sorry i should have mentioned it earlier) status (values of status rejected,approved ,pending, reviewed, reassigned) and SP is returning the values which have pending status along with RoleID, CompanyID in where clause. project with id 4 can have status pending then in next check update project with id 3 have pending status.What can i do in this case?
Can i pass the projectIDs of current project in div as a querystring to the handler and then pass it to SP an in query write something like this e.g
not in (projectids)?

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