0

I am trying to bind a list to specific columns, I can get it to autogenerate columns from the list but I want to specify a column to populate

        GridView1.DataSource = carlist;
        GridView1.DataBind();
2
  • hi your code is a little sparse, which column are you trying to populate and where are you getting the data to populate from? Commented Apr 6, 2015 at 17:38
  • You mean you want one column populated? Just set that one up as a BoundColumn wih the DataField set to the field name and HeaderText to what you want he header to be, and set AutoGenerateColumns to false. Commented Apr 6, 2015 at 20:05

1 Answer 1

1

We don't know what type carlist contains, but assuming contains car objects that have a ModelName property:

  <asp:GridView  AutoGenerateColumns="False" ID="myGrid" runat="server">

   <asp:BoundField HeaderText="Model Name" DataField="ModelName" />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.