So I have a table created that shows the properties of the landlord that is logged in. When I click on the view link, it redirects me to a new page which then I would like to display a table of the tenants that are linked to that particular property.

When view is for property number 1 clicked, this is what is shown below:
however, it is displaying the tenants of all properties, and i am unsure how to only show for that particular row. This is my code behind the second image: using System;
using System.Text;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Tenant : System.Web.UI.Page
{
//creating an empty string
string checkTenant = String.Empty;
//constructing a string called table that will be used to create a dynamic table
StringBuilder table = new StringBuilder();
protected void Page_Load(object sender, EventArgs e)
{
checkTenant += Session["LandlordLogin"];
if (!Page.IsPostBack)
{
//Creating a connection to my database using the connection string
SqlConnection con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["rent-dbConnectionString1"].ToString();
con.Open();
SqlCommand comm = new SqlCommand();
//preparing a query which will select all properties matching the landlord that is logged in at that moment
comm.CommandText = "select Tenant_FullName, Tenant_Email, Tenant_TelNum, Tenant_EmName, Tenant_EmNum, Tenant_WorkStatus from Tenants";
comm.Connection = con;
SqlDataReader rd = comm.ExecuteReader();
//creating a table depending on the data that is selected from the query
table.Append("");
");
| Full Name | ");Phone Number | ");Work Status | ");Emergency Name | ");Emergency Contact Number | ");|
|---|---|---|---|---|---|
| " + rd[0] + " | ");" + rd[1] + " | ");" + rd[2] + " | ");" + rd[3] + " | ");" + rd[4] + " | ");" + rd[5] + " | ");
PlaceHolder2.Controls.Add(new Literal { Text = table.ToString() });
rd.Close();
}
}
}
Nilesh ShahPosted Jan 2, 2018, 1:37 PM