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
narasiman rao
NA
519
771.8k
Displaying the database record in to Gridview using conditio
Aug 15 2016 7:52 AM
In table record as follows
CourseCode CoruseName Studentid City
RM Remunration 45555 1
REO Revalidation 88787 1
CTF Tanker 98889 1
ECDIS Practical 88877 1
AMOS Manual 78798 1
DFC Familarazation 87899 2
i am displaying the above data in to Gridview. code as follows
string Con= "Server=(local);initial catalog=Testing;Trusted_Connection=True";
SqlConnection sqlcon= new SqlConnection(Con);
SqlCommand cmd = new SqlCommand();
SqlDataReader dr;
cmd.CommandText = "select * from Course";
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlcon;
sqlcon.Open();
dr= cmd.ExecuteReader();
if (dr.HasRows)
{
if (reader.Read())
{
string City = dr[6].ToString();
if (City== "1") ;
{
Griview.Datasource = dr;
Gridview.databind();
}
}
}
i am checking if City 1 means. that city 1 all record to be displayed in gridview.
When i execute the above code in Gridview Output as follows
CourseCode CoruseName Studentid City
RM Remunration 45555 1
in the above gridview only first record only displayed. But not all the records in table is not displaying.
But i want the output in Gridview as follows
CourseCode CoruseName Studentid City
RM Remunration 45555 1
REO Revalidation 88787 1
CTF Tanker 98889 1
ECDIS Practical 88877 1
AMOS Manual 78798 1
please help me what is the problem in my code
Reply
Answers (
2
)
DropDownCheckBoxes and DropDownList
how to save database record in to excel using C#