Problem view records in gridview in asp.net

Posted by Dn2010 under ASP.NET on 4/3/2012 | Points: 10 | Views : 707 | Status : [Member] | Replies : 6
hi friends,
i want to check from label1(last_datetime),only view, after the records(last_datetime) in gridview.
>(greater than) is not displayed the records)

string CommandText = "select * from data where cdate > '" + Convert.ToDateTime(last_datetime) + "' Order By cdate desc limit 20";

---------------------------------------------------------------------------

public void filldate()
{

cmd.CommandText = "select top 1 cdate from data";
Label1.Text = Convert.ToString(cmd.ExecuteScalar());


}

}
---------------------------------------------------------------------------


public void fillgrid()
{

string last_datetime = Label1.Text;

string ConnectionString = @" ";

string CommandText = "select * from data where cdate > '" + Convert.ToDateTime(last_datetime) + "' Order By cdate desc limit 20";

}

---------------------------------------------------------------------------

and


how to if label1.text display no records if not in database.

please give the correct solution,

thanks in advance.




Responses

Posted by: Rajni.Shekhar on: 4/3/2012 [Member] Bronze | Points: 25

Up
0
Down
your requirement is not clear, please share what problem you are facing?

Thanks,
Rajni Shekhar

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Dn2010 on: 4/3/2012 [Member] Starter | Points: 25

Up
0
Down

i already fill date in Label from database

compare the datetime in label (last_datetime) ,then only show the latest records(greater than last_datetime) in gridview.



string last_datetime = Label1.Text;

string CommandText = "select * from data where cdate > '" + Convert.ToDateTime(last_datetime) + "' Order By cdate desc limit 20";

}

please correct this ,

thanks.

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajni.Shekhar on: 4/3/2012 [Member] Bronze | Points: 25

Up
0
Down
string CommandText = "select * from data where convert(varchar(20),cdate,103) > convert(varchar(20),'" + Convert.ToDateTime(last_datetime) + ",103)' Order By cdate desc limit 20";

check it.


Thanks,
Rajni Shekhar

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 4/3/2012 [Member] Bronze | Points: 25

Up
0
Down
Dn2010


Can You Explain Clearly

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 4/3/2012 [Member] Bronze | Points: 25

Up
0
Down
Rajni.Shekhar

is it Working????????



Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 4/3/2012 [Member] Bronze | Points: 25

Up
0
Down
Rajni.Shekha

Sorry


I DoNo Thats Why

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response