0

I have a gridview that I am dynamically creating and populating.

GridView myGrid = new GridView();
myGrid.Showfooter = true;

myGrid.Columns.Add(new BoundField() { HeaderText = "Serial #", DataField = "serial_number" });
...
...
...
myGrid.DataSource = myDS;
myGrid.DataBind();

My problem is that I'm having problems figuring out how to add a templatecolumn with a dropdownlist in it. Any ideas?

Thanks and Happy Holidays.

1 Answer 1

3

To add a dropdownlist programmatically via a templatefield you first need to create a class that implements ITemplate and pass that to the ItemTemplate property of the templatefield.

a clear example is stated here

although the example doesn't use a dropdownlist, the concept is essentially the same.

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.