2013-04-03 70 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..