SqlCommand cmd = new SqlCommand("Select _name from Computers", con); SqlDataAdapter DA = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); DA.Fill(dt); for (int i = 0; i <dt.rows.count;> { GridView2.Rows[0].Cells[1].Text = dt.Rows[1]["_name"].ToString(); }
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index [ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index] System.Collections.ArrayList.get_Item(Int32 index) +7492824 System.Web.UI.WebControls.GridViewRowCollection.get_Item(Int32 index) +13 _Default.Butto n3_Click(Object sender, EventArgs e) in c:\Users\vn73662\Desktop\MyTest\Dashboard.aspx. cs:78 System.Web.UI.WebControls.Button.On Click(EventArgs e) +111 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
GridView2.Rows[0].Cells[1].Text = dt.Rows[1]["_name"].ToString();
SqlCommand cmd = new SqlCommand("Select _name from Computers", con); SqlDataAdapter DA = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); DA.Fill(dt); GridView2.Datasource = dt; GridView2.Databind();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)