If you also encounter the stated error when you try to delete a folder, you can try to delete it using the cmd. I get the source from here.
Me error command look like this.
type " rmdir /s " follow by the direcctory name, if you are lazy to type it out ( or whatever reasons, i.e. name too long, use the tab key to help you. If your folder name contain space, do use "" to cover it up. e.g " rmdir /S "Assignment 1 ".
navigate to your directory, by using cd, then
Note: make sure you use the capital S..
to move a folder,type " move oldDirectory newDirectory".
Cheers!
Sunday, November 30, 2014
Saturday, November 22, 2014
Binding List to GridView
I encounter this error when I try to write a simple gridView. If you face the same issue, hope this help you. I found the solution here .
The one that I underlined is where I missed out. :)
The data source for GridView with id 'GridView1' did not have any properties or attributes from which to generate columns. Ensure that your data source has content.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication2
{
public class Item
{
public int Id {get; set;}
public string Name { get; set; }
}
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
List<Item> ar = new List<Item>{};
Item item = new Item(){Id = 1 , Name = "User1"};
ar.Add(item);
item.Id = 2;
item.Name= "User2";
ar.Add(item);
GridView1.DataSource = ar;
GridView1.DataBind();
}
}
wondering why you now see 2 User2 in the gridView? Then, you have to take a look on how to fill in the list .
The data source for GridView with id 'GridView1' did not have any properties or attributes from which to generate columns. Ensure that your data source has content.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication2
{
public class Item
{
public int Id {get; set;}
public string Name { get; set; }
}
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
List<Item> ar = new List<Item>{};
Item item = new Item(){Id = 1 , Name = "User1"};
ar.Add(item);
item.Id = 2;
item.Name= "User2";
ar.Add(item);
GridView1.DataSource = ar;
GridView1.DataBind();
}
}
}
wondering why you now see 2 User2 in the gridView? Then, you have to take a look on how to fill in the list .
Filled in List - From Class
Be very careful when you filling up the List. The output and how it behave.
I made a mistake that I hope will not made it again.
The part in purple colour is the outcome of the code when the debugger stop at that specific line of code.
List<Item> ar = new List<Item>{};
ar is empty. If you now access ar[0]Id, you will hit error.
ar.Add(new Item() { Id = 1, Name = "User1" });
If you now access: ar[0].Id = 1
ar.Add(new Item() { Id = 2, Name = "User2" });
If you now access: ar[0].Id = 1, ar[1].Id = 2
Item item = new Item(){Id = 3 , Name = "User3"};
ar.Add(item);
If you now access: ar[0].Id = 1, ar[1].Id = 2, ar[2].Id = 3
item.Id = 4;
item.Name = "User4";
ar.Add(item);
If you now access: ar[0].Id = 1, ar[1].Id = 2, ar[2].Id = 4, ar[3].Id = 4
I made a mistake that I hope will not made it again.
The part in purple colour is the outcome of the code when the debugger stop at that specific line of code.
List<Item> ar = new List<Item>{};
ar is empty. If you now access ar[0]Id, you will hit error.
ar.Add(new Item() { Id = 1, Name = "User1" });
If you now access: ar[0].Id = 1
ar.Add(new Item() { Id = 2, Name = "User2" });
If you now access: ar[0].Id = 1, ar[1].Id = 2
Item item = new Item(){Id = 3 , Name = "User3"};
ar.Add(item);
If you now access: ar[0].Id = 1, ar[1].Id = 2, ar[2].Id = 3
item.Id = 4;
item.Name = "User4";
ar.Add(item);
If you now access: ar[0].Id = 1, ar[1].Id = 2, ar[2].Id = 4, ar[3].Id = 4