private void GetAllSub() { Fannie.Subjects s = new Fannie.Subjects(); DataSet ds = s.GetAllSub(); DataColumn dc = new DataColumn(); dc.ColumnName = "PId"; ds.Tables[0].Columns.Add(dc); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { ds.Tables[0].Rows[i]["Pid"] = (i + 1).ToString(); } gvSub.DataKeyNames = new string[] { "SubjectID" }; gvSub.DataSource = ds; gvSub.DataBind(); }
private void GetAllSub() { Fannie.Subjects s = new Fannie.Subjects(); DataSet ds = s.GetAllSub(); //DataTable dt = new DataTable(); DataColumn dc = new DataColumn(); dc.ColumnName = "PId"; ds.Tables[0].Columns.Add(dc); //dt=ds.Tables[0]; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { ds.Tables[0].Rows[i]["Pid"] = (i + 1).ToString(); ds.Tables[0].Rows[i]["SubjectName"] = SubStr(Convert.ToString(ds.Tables[0].Rows[i]["SubjectName"]), 40); ds.Tables[0].Rows[i]["Memo"] = SubStr(Convert.ToString(ds.Tables[0].Rows[i]["Memo"]), 50); //dt.Rows[i]["SubjectName"] = SubStr(Convert.ToString(dt.Rows[i]["SubjectName"]), 40); //dt.Rows[i]["Memo"] = SubStr(Convert.ToString(dt.Rows[i]["Memo"]), 50); } gvSub.DataKeyNames = new string [] { "SubjectID" }; gvSub.DataSource = ds; gvSub.DataBind(); }