private void filteredDataInDataGridView(int memberId) { aMemberInformationBll = new MemberInformationBLL(); List<MemberInformation> aList = aMemberInformationBll.getAllMemberInformation(); List<MemberInformation> newList = new List<MemberInformation>(); foreach (var memberInformation in aList) { if (memberInformation.memberId == memberId) { newList.Add(memberInformation); } } memberInformationDataGridView.AutoGenerateColumns = false; memberInformationDataGridView.DataSource = newList; memberInformationDataGridView.Columns[1].DataPropertyName = "memberId"; memberInformationDataGridView.Columns[2].DataPropertyName = "borderName"; memberInformationDataGridView.Columns[3].DataPropertyName = "roomNo"; memberInformationDataGridView.Columns[4].DataPropertyName = "noOfMeals"; memberInformationDataGridView.Columns[5].DataPropertyName = "balance"; //Autogeneration of the id column starts here int i = 1; foreach (DataGridViewRow row in memberInformationDataGridView.Rows) { row.Cells["SNO"].Value = i; i++; } //autogeneration code ends here }
private void showDataInDataGridView() { aMemberInformationBll = new MemberInformationBLL(); memberInformationDataGridView.AutoGenerateColumns = false; List<MemberInformation> aList = aMemberInformationBll.getAllMemberInformation(); memberInformationDataGridView.DataSource = aList; memberInformationDataGridView.Columns[1].DataPropertyName = "memberId"; memberInformationDataGridView.Columns[2].DataPropertyName = "borderName"; memberInformationDataGridView.Columns[3].DataPropertyName = "roomNo"; memberInformationDataGridView.Columns[4].DataPropertyName = "noOfMeals"; memberInformationDataGridView.Columns[5].DataPropertyName = "balance"; memberInformationDataGridView.Columns[6].DataPropertyName = "individualMealCost"; memberInformationDataGridView.Columns[7].DataPropertyName = "amountToBeGiven"; memberInformationDataGridView.Columns[8].DataPropertyName = "amountToBePaid"; //Autogeneration of the id column starts here int i = 1; foreach (DataGridViewRow row in memberInformationDataGridView.Rows) { row.Cells["SNO"].Value = i; i++; } //autogeneration code ends here }