SelectedValue which is invalid because it does not exist in the list of items.

Aug 22 2010 7:08 AM
dear please help me to solve below problem....

getting error in fillgird()..
 'cmbcontractor_name' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value
dear i am sending class file..... 
 public DataTable gridviewfetch()
    {
        
        library lib = new library();
        DataTable dtdetailview = new DataTable();
        dtdetailview = lib.GetconDetail();
        return dtdetailview;
  }

and aspx page fillgrid()...

private void fillgrid()
    {
        DataTable dttab = cons.gridviewfetch();
        {

            if (dttab.Rows.Count > 0)
            {
             GridView1.DataSource = dttab;
             GridView1.DataBind();
            }
            else
            {
                dttab.Rows.Add(dttab.NewRow());
                GridView1.DataSource = dttab;
                GridView1.DataBind();

                int TotalColumns = GridView1.Rows[0].Cells.Count;
                GridView1.Rows[0].Cells.Clear();
                GridView1.Rows[0].Cells.Add(new TableCell());
                GridView1.Rows[0].Cells[0].ColumnSpan = TotalColumns;
                GridView1.Rows[0].Cells[0].Text = "No Record Found";
            }
        }


thanksyou.....

Answers (1)