Hi,
I have one GridView which is binded from Database.And I want to search the elements based on Id/First Name/Last Name.I am getting this but if there is no such item in the GridView which I entered in the TextBox,I want to get the error message in Label as"The searched record didn't found..
".
How to write code for getting this message?
This is my Code which I wrote in my button Click...
if (TxtSearch.Text == "")
{
LblSearchMsg.Text = "Please Enter the Id or First Name or Last Name..";
}
else
{
objB.id = TxtSearch.Text;
objB.First_name = TxtSearch.Text;
objB.Last_name = TxtSearch.Text;
DataSet ds = new DataSet();
ds = objD.NameBind(objB);
GridView1.DataBind();
LblSearchMsg.Visible = false;
}
{
LblSearchMsg.Text = "Please Enter the Id or First Name or Last Name..";
}
else
{
objB.id = TxtSearch.Text;
objB.First_name = TxtSearch.Text;
objB.Last_name = TxtSearch.Text;
DataSet ds = new DataSet();
ds = objD.NameBind(objB);
GridView1.DataBind();
LblSearchMsg.Visible = false;
}
In the NameBind(),I wrote this..
{
string Query = "select * from tbl_Reg where Faculty_id='" + objB.id + "' or First_name='" + objB.First_name + "' or Last_name like '%' +'" + objB.Last_name + "'+ '%'";
SqlDataAdapter da = new SqlDataAdapter(Query, con);
DataSet ds = new DataSet();
da.Fill(ds);
SqlDataAdapter da = new SqlDataAdapter(Query, con);
DataSet ds = new DataSet();
da.Fill(ds);
}
return ds;
return ds;


Rahul PrajapatRank #1,209 · 1.5K reputationPosted Jul 5, 2015, 11:52 PM EDT
LblSearchMsg.Text = "Please Enter the Id or First Name or Last Name..";
}
else
{
objB.id = TxtSearch.Text;
objB.First_name = TxtSearch.Text;
objB.Last_name = TxtSearch.Text;
DataSet ds = new DataSet();
ds = objD.NameBind(objB);
if (ds.Tables[0].Rows.Count == 0)
{
LblSearchMsg.Text = "The searched record didn't found..";
{
Vipul MalhotraRank #276 · 9.1K reputationPosted Jul 5, 2015, 11:26 PM EDT
Kanaparthi Sureshma Reddy80 reputationPosted Jul 6, 2015, 12:46 AM EDT
Govinda Rajulu YemineniRank #1,518 · 1K reputationPosted Jul 6, 2015, 2:09 AM EDT