如何使用自动生成字段将 GridView2.Columns 操作为 BoundField?索引超出范围?GridView2.Columns[6] as BoundField 我使用自动生成字段。
JobPostDataContext db = new JobPostDataContext();
var query = from j in db.JobLists
join u in db.UserLists
on j.UserID equals u.UserID
where j.JobTitle.Contains(this.TextBox1.Text)
select new
{
j.JobID,
j.JobTitle,
j.Summary,
j.Details,
j.CompanyName,
j.CompanyEmail,
j.DatePosted,
j.UserID,
u.City,
u.State,
u.Country
};
GridView2.DataSource = query;
GridView2.DataBind();
BoundField DatePosted = GridView2.Columns[6] as BoundField;
DatePosted.DataFormatString = "{0:MMM,dd yy}";