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
parthiban karnan
NA
549
101.4k
column value bind twice in dropdownlist..
Apr 24 2013 7:25 AM
column value bind twice in dropdownlist..
binded a dropdowlist[continents] with gridview.. but continents appear twice in dropdownlist..
ex: asia asia
DropDownList1.AppendDataBoundItems = true;
// String strConnString = ConfigurationManager
// .ConnectionStrings["conString"].ConnectionString;
String strQuery = "select ID, ContinentName from Continents";
SqlConnection con = new SqlConnection(str);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = strQuery;
cmd.Connection = con;
try
{
con.Open();
DropDownList1.DataSource = cmd.ExecuteReader();
DropDownList1.DataTextField = "ContinentName";
//DropDownList1.DataValueField = "Id";
DropDownList1.DataBind();
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
con.Dispose();
}
}
protected void Button1_Click1(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(str);
SqlCommand cmd = new SqlCommand("select * from NEWS where CONTINENT = '" + DropDownList1.SelectedValue + "'", con);
SqlDataAdapter Adpt = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
Adpt.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
Label1.Text = "record found";
Reply
Answers (
1
)
Response.Cache.SetCacheability(HttpCacheability.NoCache)
ASP.Net