Jump to content

datagrid binding problem


narayana_anthati
 Share

Recommended Posts

hai,When i am binding data to a datagrid i am getting error at this line plz any one help me.datagrid1.DataSource = ds.Tables("categorylist").defaultview;MY TOTAL CODE IS:SqlConnection conn = new SqlConnection("Data Source=sankhya03;Initial Catalog=OmArtPrint;Integrated Security=True"); DataSet ds = new DataSet(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { bindGrid(); } } private void bindGrid() { try { string sqlstmt = "select * from categorylist where pcid=0"; SqlDataAdapter myda = new SqlDataAdapter(sqlstmt, conn); myda.Fill(ds, "categorylist"); datagrid1.DataSource = ds.Tables("categorylist"); //datagrid1.DataSource = ds.Tables("categorylist"); //datagrid1.DataSource = ds.Tables("categorylist").defaultview; datagrid1.DataBind(); } catch (Exception ex) { Response.Write(ex.Message.ToString()); } }Thanks in advance.its very urgent.Regardsnarayana

Link to comment
Share on other sites

Watch out for case sensitivity.

datagrid1.DataSource = ds.Tables("categorylist").defaultview;

should be:

datagrid1.DataSource = ds.Tables("categorylist").DefaultView;

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...