일반 목록의 학생 세부 정보를 디자인에있는 레이블에 표시하고 싶습니다.레이블에 일반 목록 항목 표시
foreach 루프에서 오류가 발생했습니다. 즉 x is not in the current context
입니다.
namespace gentask
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = @"Data Source=Sadiq;Initial Catalog=rafi;Integrated Security=True";
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "select * from student";
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
}
}
public class student
{
student std;
List<student> stud = new List<student>();
public void load()
{
foreach (DataRow dr in x)
{
std = new stud();
std.id = x[0].Tostring();
std.name = x[1].Tostring();
std.age = x[2].Tostring();
std.school = x[3].Tostring();
std.clas = x[4].Tostring();
std.marks = x[5].Tostring();
std.grade = x[6].Tostring();
stud.Add(std);
}
}
public void show()
{
foreach (student std in stud)
{
std.id = label.text;
std.name = label1.text;
std.age = label2.text;
std.school = label3.text;
std.clas = label4.text;
std.marks = label5.text;
std.grade = Label6.Text;
}
}
}
}
'foreach는 (X에서의 DataRow의 닥터)'-. 어디 x' 정의 '입니다 – Tim
당신은 정말 천천히 시작해야 당신이 실험실에서 _anything_ 표시하는 방법을 알고 계십니까?. 엘자? "42"같은 번호 야? 먼저 해봐. –