简体   繁体   中英

Get dynamic data to display on aspx page in asp.net

I m using the below code to display profile info of a user, But as u can see its static data and thus i would have to create number of pages separately for each person.

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

Can any one specify a way so that i can insert this values directly from database when ever a specific user's profile is visited?

Instead this

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

Do this

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

And fill the data via code behind

            /*
             *  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..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM