mohammed shamsheer

mohammed shamsheer

  • 996
  • 394
  • 140k

Duplicate datagridview columns creating

Dec 23 2014 6:32 AM
DATABOUND COLUMN CREATED AUTOMATICALLY CREATING FOR DATAGRIDVIEW

I HAVE A GRID VIEW AND SOME COLUMNS EG : ROOMNO,rOOMCAPACITY,rOOrent etc

i am inserting the textbox and combobox items to datagridview 

it inserted nicely to day suddenly some databound columns is created automatically so duplicate columns in datagridveiw occured.


this is my code :


 string roomID = Convert.ToString(cmbroomno.SelectedValue);
                object[,] ParamArray = new object[,] { { "@RoomID", roomID } };
                DataSet ds = new DataSet();
                ds = DB.ExecuteQuery_SP("SelectRoomDetailsForGridByID", ParamArray);
                if (ds.Tables.Count > 0)
                {
                    int row = 0;
                    dgvcheckin.Rows.Add();
                    row = dgvcheckin.Rows.Count - 1;

                    dgvcheckin["RoomNo", row].Value = ds.Tables[0].Rows[0]["RoomNo"].ToString();
                    dgvcheckin["RoomCategoryName", row].Value = ds.Tables[0].Rows[0]["RoomCategoryName"].ToString();
                    dgvcheckin["RoomCapacity", row].Value = ds.Tables[0].Rows[0]["RoomCapacity"].ToString();
                    dgvcheckin["NoofPerson", row].Value = txtTotalHours.Text;
                    dgvcheckin["Hours", row].Value = txtTotalHours.Text;
                    dgvcheckin["InTime", row].Value = dtpchkintime.Text;
                    dgvcheckin["CheckInDate", row].Value = dtpcheckin.Text;
                    dgvcheckin["Rents", row].Value = ds.Tables[0].Rows[0]["PerdayRent"].ToString();
                    dgvcheckin["TaxAmount", row].Value = ds.Tables[0].Rows[0]["TaxAmount"].ToString();
                    dgvcheckin["CheckOutday", row].Value = dtpcheckOutdate.Text;
                    dgvcheckin["CheckOutTime", row].Value = dtpouttime.Text;
                    dgvcheckin["Roomid", row].Value = cmbroomno.SelectedValue;
                    if (Convert.ToInt32(txtTotalHours.Text) > 1)
                    {
                        double NetTotal = ((Convert.ToDouble(ds.Tables[0].Rows[0]["PerdayRent"]) + Convert.ToDouble(ds.Tables[0].Rows[0]["TaxAmount"])) + ((PolosysHMS.General.Classes.Settings.InventorySettings.ExtraHoursCost) * (Convert.ToDouble(txtTotalHours.Text) - 1)));
                        dgvcheckin.Rows[row].Cells["NetTotal"].Value = NetTotal.ToString();
                    }


any body have any idea about it

Answers (2)