TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Kanaparthi Sureshma Reddy
NA
85
38.8k
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;
Reply
Answers (
4
)
get value of textbox
FeedBack Send Only htmlpage.html form