narayana_anthati Posted October 9, 2006 Share Posted October 9, 2006 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 More sharing options...
jesh Posted October 9, 2006 Share Posted October 9, 2006 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 More sharing options...
aspnetguy Posted October 11, 2006 Share Posted October 11, 2006 does that fix the error??? If not what is the error message you are getting? Link to comment Share on other sites More sharing options...
narayana_anthati Posted October 13, 2006 Author Share Posted October 13, 2006 does that fix the error??? If not what is the error message you are getting?ok its working thank u Regards narayana Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now