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

Discussion in 'ASP .Net Web Controls' started by rmorvay, May 27, 2004.

  1. rmorvay

    rmorvay Guest

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


    --
    rmorvay
     
    rmorvay, May 27, 2004
    #1
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rmorvay
    Replies:
    2
    Views:
    5,537
    rmorvay
    May 27, 2004
  2. news.rcn.com
    Replies:
    1
    Views:
    10,298
    Chris Smith
    Jul 12, 2004
  3. Phillip Roncoroni
    Replies:
    14
    Views:
    1,401
    Toby A Inkster
    Apr 5, 2004
  4. Empire City
    Replies:
    3
    Views:
    655
    Empire City
    Apr 30, 2004
  5. Thomasa Gregg
    Replies:
    1
    Views:
    331
    Eliyahu Goldin
    Jun 9, 2004
  6. RJ
    Replies:
    1
    Views:
    432
    Eliyahu Goldin
    Feb 17, 2005
  7. Prasad Peesapati

    Making a cell editable on clicking the cell

    Prasad Peesapati, Feb 3, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    211
    Prasad Peesapati
    Feb 3, 2005
  8. Replies:
    2
    Views:
    482
    Thomas 'PointedEars' Lahn
    Aug 5, 2008
Loading...