Searching the element from GridView and display in Label?

Jul 6 2015 2:53 AM
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;
}
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);
}
return ds; 

Answers (4)