public void RoomDetailsBlankData()
{
try
{
DataTable dt1 = new DataTable();
// dt1.Columns.AddRange(new DataColumn[8] { new DataColumn("Room_ID"), new DataColumn("Room_Num"), new DataColumn("CheckIN_Date", typeof(DateTime)), new DataColumn("CheckOUT_Date", typeof(DateTime)), new DataColumn("Duration"), new DataColumn("Fare"), new DataColumn("BookStatus_ID"), new DataColumn("Book_Status") });
dt1.Columns.AddRange(new DataColumn[10] { new DataColumn("Room_ID"), new DataColumn("Room_Num"), new DataColumn("CheckIN_Date", typeof(DateTime)), new DataColumn("CheckIN_Time", typeof(DateTime)), new DataColumn("CheckOUT_Date", typeof(DateTime)), new DataColumn("CheckOUT_Time", typeof(DateTime)), new DataColumn("Duration"), new DataColumn("Fare"), new DataColumn("BookStatus_ID"), new DataColumn("Book_Status") });
ViewState["BookingDetails"] = dt1;
grdRoomDetails.DataSource = (DataTable)ViewState["BookingDetails"];
grdRoomDetails.DataBind();
}
catch (Exception)
{
throw;
}
}
protected void AddRoom(object sender, EventArgs e)
{
try
{
if (txtBookTill.Text != "" && txtBookFrom.Text != "" && txtDuration.Text != "")
{
DataTable dt1 = (DataTable)ViewState["BookingDetails"];
DateTime date1 = new DateTime();
DateTime date2 = new DateTime();
date1 = DateTime.ParseExact(this.txtBookFrom.Text.Trim(), "dd-MM-yyyy", null);
date2 = DateTime.ParseExact(this.txtBookTill.Text.Trim(), "dd-MM-yyyy", null);
string BookinFromDate = date1.ToString();
string BookingTillDate = date2.ToString();
string CheckInTime = Convert.ToDateTime(this.txtCheckINTime.Text.Trim()).ToString("hh:mm tt");
string CheckOutTime = Convert.ToDateTime(this.txtCheckoutTime.Text.Trim()).ToString("hh:mm tt");
System.DateTime ObjLocDate = default(System.DateTime);
string StrLocTime = txtCheckINTime.Text;
ObjLocDate = Convert.ToDateTime(StrLocTime);
//dt1.Rows.Add(drpRoomNum.SelectedValue, drpRoomNum.SelectedItem.Text.Trim(), txtBookFrom.Text.Trim(), txtBookTill.Text.Trim(), txtDuration.Text.Trim(), txtRoomFare.Text.Trim(), drpBookingStatus.SelectedValue, drpBookingStatus.SelectedItem.Text.Trim());
//dt1.Rows.Add(drpRoomNum.SelectedValue, drpRoomNum.SelectedItem.Text.Trim(), BookinFromDate, BookingTillDate, txtDuration.Text.Trim(), txtRoomFare.Text.Trim(), drpBookingStatus.SelectedValue, drpBookingStatus.SelectedItem.Text.Trim());
dt1.Rows.Add(drpRoomNum.SelectedValue, drpRoomNum.SelectedItem.Text.Trim(), BookinFromDate, CheckInTime, BookingTillDate, CheckOutTime, txtDuration.Text.Trim(), txtRoomFare.Text.Trim(), drpBookingStatus.SelectedValue, drpBookingStatus.SelectedItem.Text.Trim());
ViewState["BookingDetails"] = dt1;
grdRoomDetails.DataSource = (DataTable)ViewState["BookingDetails"];
grdRoomDetails.DataBind();
GetTotal();
}
else
{
}
}
catch (Exception ex)
{
throw;
}
}
protected void btnRemoveRoom_Click(object sender, EventArgs e)
{
try
{
LinkButton lb = (LinkButton)sender;
GridViewRow gvRow = (GridViewRow)lb.NamingContainer;
int rowID = gvRow.RowIndex;
if (ViewState["BookingDetails"] != null)
{
DataTable dt = (DataTable)ViewState["BookingDetails"];
if (dt.Rows.Count > 0)
{
if (gvRow.RowIndex < dt.Rows.Count)
{
//Remove the Selected Row data
dt.Rows.Remove(dt.Rows[rowID]);
}
}
//Store the current data in ViewState for future reference
ViewState["BookingDetails"] = dt;
//Re bind the GridView for the updated data
grdRoomDetails.DataSource = dt;
grdRoomDetails.DataBind();
GetTotal();
}
DataTable dt1 = (DataTable)ViewState["BookingDetails"];
if (dt1.Rows.Count == 0)
{
if (gvRow.RowIndex == dt1.Rows.Count)
{
}
}
}
catch (Exception ex)
{
throw;
}
}
Ignore that GuestDetailsBlankData() method