Binding a DropDownList to a cell in a grid...

R

rmorvay

I am trying to dynamically build a dropdownlist and bind it to a cell in a
grid. I tried to utilize the following code but I am stuck at the point
where I bind the dropdownlist to the grid cell. I get the following message
for this code but I suspect that the "
UltraWebGrid1.Rows[intCtr].Cells[3].Value = ddlGeography;" is not how you
bind the dropdownlist control to the grid. ERROR: "The type
'System.Web.UI.WebControls.DropDownList' must be marked as Serializable or
have a TypeConverter other than ReferenceConverter to be put in viewstate."

Any insight would be appreciated. This is test code so don't worry about
hte fact that each grid cell will have one dropdownlist control with IL and
60014 as the only row.

for (int intCtr = 0; intCtr <= UltraWebGrid1.Rows.Count - 1;intCtr++)
{
DataSet dsGeography = new DataSet();

DataTable dtGeography = dsGeography.Tables.Add("Geography");
dtGeography.Columns.Add("State", typeof(string));
dtGeography.Columns.Add("ZipCode", typeof(string));
DataRow dr;
dr = dsGeography.Tables[0].NewRow();
dr["State"] = "IL";
dr["ZipCode"] = "60014";

DropDownList ddlGeography = new DropDownList();
ddlGeography.DataSource = dsGeography;
ddlGeography.DataBind();

UltraWebGrid1.Rows[intCtr].Cells[3].Value = ddlGeography;

dsGeography = null;
dtGeography = null;
dr = null;
}
 

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,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top