Click here to Skip to main content
15,899,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I am going to build schedule for 7 days in gridview for different rooms. but i dont know how i can achieve this formating in gridview. Right now i build schedule in html table. here is my web page image which shows the schedule formatting.
Here is the Image link
http://www.freeimagehosting.net/069d4[^]

here is my aspx code. i want to same formatting in the gridview. I am not expert in the gridview so please help me with some example code how i can achieve this.

C#
<%@ Page Title="Schema" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="Schema.aspx.cs" Inherits="_Default" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import namespace="System.Data.SqlClient" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
   
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
    </style>

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
 <asp:ScriptManager ID="ScriptManager1" runat="server">
    
 
    <%--Schema Header Table--%>
    <table cellpadding="0" cellspacing="0" class="style1">
        <tr>
            <td colspan="5" style="text-align: center; padding-removed 100px;">
                
                           Schema för anläggning:  
                    <asp:DropDownList ID="ddKontor" runat="server" AutoPostBack="True" 
                               onselectedindexchanged="Page_Load">
                        <asp:ListItem Value="O">Odenplan
                        <asp:ListItem Value="S">Strandvägen
                    
                
                           <asp:Label ID="lbmsg" runat="server" ForeColor="Red" Visible="False">
                
            </td>
        </tr>
        <tr>
            <td style="text-align: center; padding-removed 5px;">
                <asp:LinkButton ID="lbForegvecka" runat="server" CommandName="PreviousWeek" 
                    oncommand="lbForegvecka_Command">Föreg vecka
                </td>
            <td style="text-align: center; padding-removed 5px;">
                <asp:LinkButton ID="lbForegmanad" runat="server" CommandName="PreviousMonth" 
                    oncommand="lbForegmanad_Command">Föreg månad
                </td>
            <td style="text-align: center; padding-removed 5px;">
                <asp:TextBox ID="TxtStartDate" runat="server" AutoPostBack="True" 
                    ontextchanged="Page_Load">
                <asp:CalendarExtender ID="TxtStartDate_CalendarExtender" runat="server" 
                    Enabled="True" TargetControlID="TxtStartDate">
                
                </td>
            <td style="text-align: center; padding-removed 5px;">
                <asp:LinkButton ID="lbNastamanad" runat="server" CommandName="NextMonth" 
                    oncommand="lbNastamanad_Command">Nästa månad
                </td>
            <td style="text-align: center; padding-removed 5px;">
                <asp:LinkButton ID="lbNastavecka" runat="server" CommandName="NextWeek" 
                    oncommand="lbNastavecka_Command">Nästa vecka
                </td>
        </tr>
        </table>
    <%--Week Days Column--%>
   <center>
   <table border="1" style="font-weight: bold;	text-align: center;	vertical-align: middle; background-color: #CACACA;">
           cellpadding="0" cellspacing="2" frame="box">
        <tr>
            <th>
                Rum
            </th>

            <% 
                string[] temp= new string[2];
                for (int i = 0; i < 7; i++)
                {
                    temp = AddDate(Convert.ToDateTime(TxtStartDate.Text), i);
            %>
            <th>
                <% Response.Write (temp[0]);
                   Response.Write("<br />");
                   Response.Write (temp[1]);
                %>
            </th>
            <%
                    temp[0] = "";
                    temp[1] = "";

                } 
            %>
        </tr>
        <%--Show Rums and Booking Information--%>        <%
                try
                {
                    
                    //DataBase OledbConnection
                    Connection conn = new Connection();
                    conn.OledbConntion();
                    conn.OpenOledbConnection();
                    
                    //DataBase SqlConnection
                    Connection sqlConn = new Connection();
                    sqlConn.SqlConnection();
                    
                    
                    
                    string sql = "SP_SchemaRumList '"+ddKontor.SelectedValue+"','"+TxtStartDate.Text+"'";   
                    System.Data.OleDb.OleDbCommand cmd = new OleDbCommand(sql,conn.oledbconn);
                    System.Data.OleDb.OleDbDataAdapter da = new OleDbDataAdapter(cmd);
                    System.Data.DataTable dt = new DataTable("SP_SchemaRumList");
                    da.Fill(dt);
                    for(int i=0; i                    {
                        
        %>
        <tr>
            <td>
            <a href="VisaRum.aspx?RumId=<% Response.Write(dt.Rows[i][" id="]+" hold=" />                <%= dt.Rows[i][" benamning="]%><br mode=" rumbokbokningarexistrumdatum=", sqlConn.sqlconn);<br mode=" returnvalue=", SqlDbType.Int);<br mode=" rumid=", SqlDbType.Int);<br mode=" datum=", SqlDbType.DateTime);<br mode=" rumbokbokningarbyrumdatum=" + dt.Rows[i][" sp_schemarumlist=");<br mode=" status="].ToString() == " pre=")<br mode="><div style="\"border:" medium="" solid=" + dt1.Rows[b][" farg="].ToString() + " mode="hold" />                            Response.Write("<a href="VisaBoka.aspx?BookingID="" mode="hold" />                            if (dt1.Rows[b]["RumID"].ToString() == dt1.Rows[b]["HuvudRumID"].ToString())
                                Response.Write("");
                                    Response.Write(dt1.Rows[b]["Kortnamn"].ToString());
                            if (dt1.Rows[b]["RumID"].ToString() == dt1.Rows[b]["HuvudRumID"].ToString())
                                        Response.Write(""); 
                                Response.Write("</a>");
                                Response.Write("<br />");
                                Response.Write(dt1.Rows[b]["AnsVardinna"].ToString());
                                Response.Write("<br />");
                                Response.Write("("+dt1.Rows[b]["Fran"].ToString()+" - "+dt1.Rows[b]["Till"]+")");
                            Response.Write("");
                        Response.Write("<br />");
                        }
                    }
                    @sqlConn.CloseSqlConnection();
                }
                        
                %>
            </td>
        </tr>
        <%
                    }//Room List For Loop
          conn.CloseOledbConnection(); 
          } // Try block
                catch (Exception exc)
                {
                    lbmsg.Visible = true;
                    lbmsg.Text = exc.Message.ToString();
                }
        %>
        </table>
        
    </center>


Thanks in advance
Posted

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