Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I have a page that displays salary of a staff. In another page I want to show this page like if we have 10 staff then for all the 10 staff that particular page is shown separately at the same time.

I'm using I frame to do so but it only shows single page for one staff only. Please help me with the issue.
My code behind to access the salary page is


C#
protected void BindPrimaryGrid()
    {
        con.Open();
        SqlDataAdapter sda = new SqlDataAdapter("select * from Salary Where Year='" + Year + "' AND Month='" + PreviousMonth + "' AND Updated='True'";, con);
        DataTable dt = new DataTable();
        sda.Fill(dt);
        con.Close();
        if (dt.Rows.Count > 0)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                HtmlIframe ifrm = new HtmlIframe();
                ifrm.ID = dt.Rows[i]["REFNo"].ToString();
                ifrm.Src = "StaffSalaryPrint.aspx?REFNo=" + dt.Rows[i]["REFNo"].ToString();
                pnlContents.Controls.Add(ifrm);
            }         
        }


What I have tried:

I've tried to add Iframes dyanamically to do so.
But sadly it doesn't work. Iframe only works for a single row and not in a loop.
Posted
Updated 10-Mar-16 22:37pm
Comments
[no name] 11-Mar-16 1:09am    
Can you please specify your requirement properly? For displaying the details of the 10 users you need not to have iframes exactly. You can have a listview/gridview/repeater control to display the details rather.
Richard Deeming 11-Mar-16 5:13am    
Your code is vulnerable to SQL Injection[^].

NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.

You need not to iframe for it. when you passing QueryString (REFNo) on StaffSalaryPrint.aspx page, Here you can create anchor tag and give href as like StaffSalaryPrint.aspx?REFNo='your ref id'.

After that Access querystring on staffsalaryprint page and show data according to RerNo.

now whenever you click any anchor tag, corresponding employee Detail will show on next page.

Regards,
AARIF SHAIKH
 
Share this answer
 
Use ASP:Repeater control

put the form you need to show into itemtemplate and bind the data in repeateritemdatabound event to show separate forms.

Good luck
 
Share this answer
 

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