Dynamic Table Generate and Fill Data
sample.aspx
<div id = "roomsdiv" runat="server">
</div>
sample.aspx.cs
fds = cls.selectFloor();
DataRowCollection fcdr = fds.Tables[0].Rows;
table = "<table align='center' style='width: 70%' border='0'>";
foreach (DataRow fdr in fds.Tables[0].Rows)
{
table += "<tr>";
table += "<tr>";
rds = cls.selectRoom(fdr["floorid"].ToString());
if (rds.Tables[0].Rows.Count > 0)
{
table += "<td height='20' width ='40' class='roomfloor'>" + fdr["floorname"] + "</td>";
table += "<td height='20' width ='10'> </td>";
foreach (DataRow rdr in rds.Tables[0].Rows)
{
if (rdr[1].ToString() == "1")
{
//table += "<td height='20' width ='30' class='roomavail'><a href='javascript: window.open(Customer_CheckIn.aspx?id=" + rdr["roomno"] + "'>" + rdr["roomno"] + "</a></td>";
//string roomno= "<div class='myBox' onmouseover='this.style.cursor=hand' ><a href=Customer_CheckIn.aspx?id=" + rdr["roomno"] + ">" + rdr["roomno"] + "</a></div>";
//table += "<td height='20' width ='30' class='roomavail'>"+roomno +"</td>";
table += "<td height='20' width ='30' class='roomavail' title='Book room no "+rdr["roomno"]+"'><a href=Customer_CheckIn.aspx?id=" + rdr["roomno"] + ">" + rdr["roomno"] + "</a></td>";
table += "<td height='20' width ='1'> </td>";
// <a href=""javascript: window.open('terms/" & Request.QueryString("id") & ".html','test',config='width=750,height=300,left=100 ,top=150, menubar=no,toolbar=no,help=no,status=no,resizable=0','status=no'); void('');"" '>
// table += "<td height='20' width ='10'> </td>";
}
else
{
if (rdr[1].ToString() == "2")
{
table += "<td height='20' width ='30' class='roomnotavail' title='Room Filled'>" + rdr["roomno"] + "</td>";
table += "<td height='20' width ='1'> </td>";
//table += "<td height='20' width ='10'> </td>";
}
else
{
table += "<td height='20' width ='30' class='roommaintain' title='Room under maintenance'>" + rdr["roomno"] + "</td>";
table += "<td height='20' width ='1'> </td>";
}
}
}
}
}
table +="</tr></tr></table>";
roomsdiv.InnerHtml = table;
}
Methods :
public DataSet selectFloor()
{
DataSet ds = new DataSet();
Hotel_DataObject obj = new Hotel_DataObject(false);
string cmd = "select FloorId,floorname from floor";
ds = obj.ExecuteDataSet(cmd);
return ds;
}
public DataSet selectRoom(string floorid)
{
DataSet ds = new DataSet();
Hotel_DataObject obj = new Hotel_DataObject(false);
string cmd = "select RoomNo, StatusId FROM RoomInfo where floorid = '" + floorid + "' ";
ds = obj.ExecuteDataSet(cmd);
return ds;
}
sample.aspx
<div id = "roomsdiv" runat="server">
</div>
sample.aspx.cs
fds = cls.selectFloor();
DataRowCollection fcdr = fds.Tables[0].Rows;
table = "<table align='center' style='width: 70%' border='0'>";
foreach (DataRow fdr in fds.Tables[0].Rows)
{
table += "<tr>";
table += "<tr>";
rds = cls.selectRoom(fdr["floorid"].ToString());
if (rds.Tables[0].Rows.Count > 0)
{
table += "<td height='20' width ='40' class='roomfloor'>" + fdr["floorname"] + "</td>";
table += "<td height='20' width ='10'> </td>";
foreach (DataRow rdr in rds.Tables[0].Rows)
{
if (rdr[1].ToString() == "1")
{
//table += "<td height='20' width ='30' class='roomavail'><a href='javascript: window.open(Customer_CheckIn.aspx?id=" + rdr["roomno"] + "'>" + rdr["roomno"] + "</a></td>";
//string roomno= "<div class='myBox' onmouseover='this.style.cursor=hand' ><a href=Customer_CheckIn.aspx?id=" + rdr["roomno"] + ">" + rdr["roomno"] + "</a></div>";
//table += "<td height='20' width ='30' class='roomavail'>"+roomno +"</td>";
table += "<td height='20' width ='30' class='roomavail' title='Book room no "+rdr["roomno"]+"'><a href=Customer_CheckIn.aspx?id=" + rdr["roomno"] + ">" + rdr["roomno"] + "</a></td>";
table += "<td height='20' width ='1'> </td>";
// <a href=""javascript: window.open('terms/" & Request.QueryString("id") & ".html','test',config='width=750,height=300,left=100 ,top=150, menubar=no,toolbar=no,help=no,status=no,resizable=0','status=no'); void('');"" '>
// table += "<td height='20' width ='10'> </td>";
}
else
{
if (rdr[1].ToString() == "2")
{
table += "<td height='20' width ='30' class='roomnotavail' title='Room Filled'>" + rdr["roomno"] + "</td>";
table += "<td height='20' width ='1'> </td>";
//table += "<td height='20' width ='10'> </td>";
}
else
{
table += "<td height='20' width ='30' class='roommaintain' title='Room under maintenance'>" + rdr["roomno"] + "</td>";
table += "<td height='20' width ='1'> </td>";
}
}
}
}
}
table +="</tr></tr></table>";
roomsdiv.InnerHtml = table;
}
Methods :
public DataSet selectFloor()
{
DataSet ds = new DataSet();
Hotel_DataObject obj = new Hotel_DataObject(false);
string cmd = "select FloorId,floorname from floor";
ds = obj.ExecuteDataSet(cmd);
return ds;
}
public DataSet selectRoom(string floorid)
{
DataSet ds = new DataSet();
Hotel_DataObject obj = new Hotel_DataObject(false);
string cmd = "select RoomNo, StatusId FROM RoomInfo where floorid = '" + floorid + "' ";
ds = obj.ExecuteDataSet(cmd);
return ds;
}
Comments
Post a Comment