my gridview1
is connected to sqldatasource1
and now i create a search command using searchBOX.text
and search_button
var ds = new DataSet();
using (var newconnection = new SqlConnection(ConfigurationManager.ConnectionStrings["User_DB_Connectionstring"].ConnectionString))
{
strconn = "select * from User_TBL_DB where (Firstname like '%@search%')";
var xp = new SqlCommand(strconn, newconnection);
xp.CommandType = CommandType.Text;
xp.Parameters.AddWithValue("@search", SearchBOX.Text);
newconnection.Open();
xp.ExecuteNonQuery();
var da = new SqlDataAdapter();
da.SelectCommand = xp;
da.Fill(ds, "Name");
}
GridView1.DataSource = ds;
GridView1.DataBind();
i have a problem with GridView1.Datasource =ds;
and my datasourceID which is datasourceID="sqlDatasource1"
it always give me this error """Both DataSource and DataSourceID are defined on 'GridView1'. Remove one definition.""
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Align="Center"
BackColor="#DEBA84" BorderColor="#DEBA84" BorderWidth="1px"
CellPadding="3" ShowFooter="True"
Width="713px" BorderStyle="None" CellSpacing="2"
onrowcommand="GridView1_RowCommand" DataSourceID="SqlDataSource1"
onrowdeleting="GridView1_RowDeleting1" AutoGenerateSelectButton="True"
onselectedindexchanged="GridView1_SelectedIndexChanged"
AllowPaging="True" >
How am i going to fix this?