Gridview, TemplateField Programmatically.

  • Thread starter cook.jonathan.m
  • Start date
C

cook.jonathan.m

I want to programmatically add a dropdown to each row in a certain
column returned to the gridview by my query. I want to do this
entirely in behind-code. My gridview tag in the page will have the
following code and no more.

<asp:GridView ID="gv" runat="server"
AutoGenerateColumns="false">
</asp:GridView>

Now, I have generated boundfields to add regular data without a
control to the gridview.
Example:

foreach (DataColumn col in tempTable.Columns)
{
BoundField bField = new BoundField();
bField.HtmlEncode = false;
bField.DataField = col.ColumnName.ToString();
bField.HeaderText = col.ColumnName.ToString();
gv.Columns.Add(bField);
}

That's fine, but in one of these columns that comes back, I want it to
contain a dropdownlist that could be filled from a separate sql query
and also have this column be editable.

I've referenced http://www.dotnet247.com/247reference/msgs/13/65435.aspx
and doing such with a dropdownlist, instead of a button doesn't kill
off my page, but it also does not load my dropdownlist.

Any ideas?

-Jonathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top