about grid view

Dec 29 2010 7:48 AM

hai,
by using the two grid views when i using this coding.i have an error like  "Both DataSource and DataSourceId are different,Remove one definition.How can i solve this
public
void bind()
{
//string tid = ddlTitle.SelectedItem.Value.ToString();
string str = Request.QueryString["titlename"];
string connectionstring = @"data source=System-7\sqlExpress;initial catalog=Project;User ID=sa;Password=as;";
SqlConnection con = new SqlConnection(connectionstring);
con.Open();
string query = "select title,suggestion,owner,date from topic1 where title='" + str + "'";
SqlCommand cmd = new SqlCommand(query, con);
GridView1.DataSource = cmd.ExecuteReader();
GridView1.DataBind();
con.Close();
}
public void loadreply()
{
string str1 = Request.QueryString["user1"];
string connectionstring = @"data source=System-7\sqlExpress;initial catalog=Project;User ID=sa;Password=as;";
SqlConnection con = new SqlConnection(connectionstring);
con.Open();
string query = "select topic1.owner,replies.sender,replies.suggestion,replies.date from replies,topic1 where replies.user1= topic1.owner ";
SqlCommand cmd = new SqlCommand(query, con);
GridView2.DataSource = cmd.ExecuteReader();
GridView2.DataBind();
con.Close();
}

Answers (1)