Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
DATABOUND COLUMN CREATED AUTOMATICALLY  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
Posted
Updated 23-Dec-14 17:30pm
Comments
Sinisa Hajnal 24-Dec-14 4:34am    
Turn off autogenerate columns and do it yourself. Better control, custom titles instead of column names, different styling if you want it, ability to have columns in the data that are not shown...many advantages for little additional work.
SamsCool 25-Dec-14 6:38am    
ya i turned off autogenerated columns....my mistake is i bind the dgv in other part of code and finded it and solved....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900