I am tring to set the data of the Webgrid on run time using Datasource,
can any one tell me how to do it?
my code is:
DataSet DS = new DataSet();
SqlDataReader sqlDR;
System.Data.SqlClient.
SqlConnection cn = new System.Data.SqlClient.SqlConnection();
cn.ConnectionString =
"Data Source=OFIRN2;Initial Catalog=SRIIDatabase;Integrated Security=True";
cn.Open();
System.Data.SqlClient.
SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
cmd.Connection = cn;
cmd.CommandText =
"SELECT UserName, Priority, MailAddress, ViewPermission, RunningPermission, EditPermission, DeletePermission, Status FROM UsersTable WHERE (UserName LIKE 'david')";
cmd.CommandType =
CommandType.Text;
sqlDR = cmd.ExecuteReader();
Grid1.Datasource = sqlDR;
Grid1.DataBind();
the propleam is that i have exceprion when trying to assisn the datasource (columns Item exists).
there is any why to auto configure columns and data
Thanks
Ofir