سلام من میخوام در یه gridview ببا استفاده از SqlDataSource به صورت کد اطلاعاتی رو قرار بدم، میدونم به صورت ویزاردی راحت میشه SqlDataSource vرو مقدار دهی کرد ولی من نیاز دارم این کار رو با کد انجام بدم من یه شی ساختم از SqlDataSource و از روی پراپرتی یه SqlDataSource دیگه که ویزاردی ساختم به SqlDataSource خودم مقدار دهی کردم به صورت زیر :


SqlDataSource s = new SqlDataSource();
s.ConnectionString = "Data Source=.;Initial Catalog=MYDB;Integrated Security=True";
s.ProviderName = "System.Data.SqlClient";
s.ID = "SqlDataSource2";
s.SelectCommand = "SELECT * FROM [tblUser]";

GridView2.DataSourceID = "SqlDataSource2";


اما بعد از اجرا ارور زیر رو میگیرم .
کد HTML:
Server Error in '/test2' Application.

The DataSourceID of 'GridView2' must be the ID of a control of type IDataSource.  A control with ID 'SqlDataSource2' could not be found.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Web.HttpException: The DataSourceID of 'GridView2' must be the ID of a control of type IDataSource.  A control with ID 'SqlDataSource2' could not be found.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[HttpException (0x80004005): The DataSourceID of 'GridView2' must be the ID of a control of type IDataSource.  A control with ID 'SqlDataSource2' could not be found.]
   System.Web.UI.WebControls.DataBoundControl.GetDataSource() +9555130
   System.Web.UI.WebControls.DataBoundControl.ConnectToDataSourceView() +58
   System.Web.UI.WebControls.DataBoundControl.GetData() +4
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +54
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +30
   System.Web.UI.WebControls.GridView.DataBind() +4
   System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +105
   System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +75
   System.Web.UI.Control.EnsureChildControls() +83
   System.Web.UI.Control.PreRenderRecursiveInternal() +42
   System.Web.UI.Control.PreRenderRecursiveInternal() +168
   System.Web.UI.Control.PreRenderRecursiveInternal() +168
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +974

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929
لطفا دوستان راهنمایی کنید؟