Index outof range? Automatica generate field .How to manipulate GridView2.Columns as BoundField;

Posted by mike on Stack Overflow See other posts from Stack Overflow or by mike
Published on 2011-03-13T22:49:57Z Indexed on 2011/03/14 0:09 UTC
Read the original article Hit count: 119

Index outof range?GridView2.Columns[6] as BoundField I use Automatica generate field . How to manipulate GridView2.Columns as BoundField with auto-generate feather?

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}";

© Stack Overflow or respective owner

Related posts about gridview

Related posts about string-formatting