2013-04-03 76 views
0

我使用下面的代碼來顯示用戶的個人資料信息,但是由於您可以看到它的靜態數據,因此我將不得不分別爲每個頁面創建多個頁面人。獲取動態數據以顯示在asp.net中的aspx頁面

   <td valign="top" class="main_text" > 
        <h1>Attendance Dashboard</h1> 
         <table cellspacing="0" cellpadding="0" border="0" width="100%"> 
          <tr> 
           <td></br></br> 
            <table cellspacing="0" cellpadding="0" border="0" width="100%"> 
             <tr> 
              <td> 
               <h3 style="display:inline;">Name:</h3> <h4 style="display:inline;" >Usman Abdullah</h4> 
              </td> 
             </tr> 
             <tr> 
              <td> 
               <h3 style="display:inline;">Gender:</h3> <h4 style="display:inline;" >Male</h4> 
              </td> 
             </tr> 
             <tr> 
              <td> 
               <h3 style="display:inline;">Department:</h3> <h4 style="display:inline;" >BS Computer Science</h4> 
              </td> 
             </tr> 
             <tr> 
              <td > 
               <h3 style="display:inline;">Designation:</h3> <h4 style="display:inline;" >Student</h4> 
              </td> 
             </tr> 

             <tr> 
              <td> 
               <h3 style="display:inline;">Number:</h3> <h4 style="display:inline;" >0333-1234567</h4> 
              </td> 
             </tr> 
            </table> 
           </td> 

           <td width="400px" align="center"> 
           <BR/><BR/> 
            <img src="css/images/profile_pic.jpg"> 
           </td> 
          </tr> 

任何一個可以指定方式,這樣我可以永遠特定用戶的個人資料被訪問時,直接從數據庫中插入這個值?

+0

您正在使用ASP.Net或傳統的ASP?他們*完全*不同。 – Amy

+0

asp.net,對不起。我不知道它 – saadsafdar

+0

我要猜測(所以不是答案)在這裏,你使用的是asp.net,在這種情況下,你應該看看數據綁定和[objectdatasource](http:// msdn .microsoft.com/EN-US /庫/ system.web.ui.webcontrols.objectdatasource(v = VS.90)的.aspx)。 – Destrictor

回答

0

而是這個

<h3 style="display:inline;">Name:</h3> <h4 style="display:inline;" >Usman Abdullah</h4> 

做這個

<h3 style="display:inline;">Name:</h3> <h4 style="display:inline;" ><asp:Literal ID="lblName" runat="server" /></h4> 

,並通過代碼填充數據背後

  /* 
      * When you access an user profile like www.yoursite.com/user.aspx?userId=3 
      * You must get the parameter "userId=3" and search in database for the user with ID = 3 
      * and return an object with its data 
      */ 
      User user = GetUserFromDatabase(Int32.Parse(Request["userId"])); 

      /* 
      * And put dynamically in the page like 
      */ 
      lblName.Text = user.Name; 
      lblDepartment.Text = user.Department; 
      //and go on..