我使用此代码仅获得 1 条记录,但我想在页面上显示多条记录。我在页面上显示 3 列,它们是id
:name
和lastname
。我怎样才能完成这项工作?
代码背后:
protected List<Class1> GetClass1()
{
Class1 uinfo = new Class1();
uinfo.ID = Convert.ToInt16(TextBox1.Text);
uinfo.Name = TextBox2.Text;
uinfo.LastName = TextBox3.Text;
data.Add(uinfo);
return data;
}
protected void BindUserDetails()
{
data = GetClass1();
GridView1.DataSource = data;
GridView1.DataBind();
}
类文件:
public class Class1
{
Int16 id;
string name = string.Empty;
string lastname = string.Empty;
public Int16 ID
{
get { return id; }
set { id = value; }
}
public string Name
{
get { return name; }
set { name = value; }
}
public string LastName
{
get { return lastname; }
set { lastname = value; }
}
}