Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
200
how to add a row to a webcombo at runtime
posted


Hi all,

I have a webcombo in my page. Is it possible to add a row dynamically in a webcombo just
like adding items to dropdownlist at runtime.

Thanks

  • 25
    posted

    This isn't pretty, but atleast it's working:

     

            WebCombo_Name.DataBind(); // need to do this, to get colums from original datasource

            WebCombo_Name.Rows.Add("-1"); // -1 here is a unique key, you need for finding your row

            WebCombo_Name.Rows.FromKey("-1").Cells[0].Value = 2; // you need it here to locate the added row, you'll be modifying

            WebCombo_Name.Rows.FromKey("-1").Cells[3].Text = "Some text here"; // here you can set values for cells

            WebCombo_Name.DataBind(); // need to bind again to make added row visible.