0

我正在使用下面的代码来显示用户的个人资料信息,但是你可以看到它的静态数据,因此我必须为每个人分别创建页面数。

                <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>

任何人都可以指定一种方式,以便我可以在访问特定用户的个人资料时直接从数据库中插入这些值吗?

4

1 回答 1

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..
于 2013-09-23T19:52:56.560 回答