WebGrid Community Server

Welcome to WebGrid Community Server Sign in | Join | Help
in Search

seting WebGrid data in run time

Last post 08-06-2008, 7:28 by admin. 1 replies.
Sort Posts: Previous Next
  •  08-05-2008, 7:41 708

    seting WebGrid data in run time

    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

  •  08-06-2008, 7:28 712 in reply to 708

    Re: seting WebGrid data in run time

    WebGrid does not map 'SqlDataReader' correctly. So Please provide the property with a DataTable or similar.

    I will look into this issue.

    Olav Botterli, WebGrid Founding Developer
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems