Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
date wise filter record in gridview in asp.net
Sk Jha
Jan 13 2018 9:35 PM
102
Reply
My code is not working for date wise filter record and bind to gridview. giving error
Conversion failed when converting date and/or time from character string.
my code is
protected
void
btnShow_Click(
object
sender, EventArgs e)
{
try
{
SqlCommand cmd =
new
SqlCommand(
"select * from OrraStock_Sales where createDate between '@fromDt' and '@toDt'"
, con);
cmd.Parameters.AddWithValue(
"@fromDt"
,txtFromDt.Text);
cmd.Parameters.AddWithValue(
"@toDt"
,DateTime.Parse(txtToDt.Text));
con.Open();
SqlDataAdapter da =
new
SqlDataAdapter(cmd);
ds =
new
DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
lblTotRecord.Text =
""
+ ds.Tables[0].Rows.Count;
con.Close();
}
catch
(Exception ex)
{ Response.Write(ex.Message); }
}
Please help me.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
when call db.SaveChanges() Appear this Exception
how to check already existing record in mvc