I have a list view binded to an sqlquery to a ListView. What I want is on click to load data and display for Unitatea 1 but click on Unitatea 2 to hide data for Unitatea 1 and display data only for Unitatea 2.
HTML
code behind
protected void LV1_Click(object sender, EventArgs e)
{
Button cmd = (Button)sender;
ListViewItem ObiectivRow = (ListViewItem)cmd.NamingContainer;
TextBox id = (TextBox)ObiectivRow.FindControl("txtIDOB");
ListView LV2 = (ListView)ObiectivRow.FindControl("LV2");
int idob = Convert.ToInt32(id.Text);
List prm = new List
{
new SqlParameter("@IdOB", idob)
};
LV2.DataSource = GetDataTable("SELECT DISTINCT IdCL,Cladire FROM tblCladire WHERE IdOB= @IdOB;", prm);
LV2.DataBind();
}
protected void LV2_Click(object sender, EventArgs e)
{
Button cmd = (Button)sender;
ListViewItem CladireRow = (ListViewItem)cmd.NamingContainer;
TextBox id = (TextBox)CladireRow.FindControl("txtIDCL");
int idcl = Convert.ToInt32(id.Text);
ListView LstCamera = (ListView)CladireRow.FindControl("LV3");
List prm = new List
{
new SqlParameter("@IdCL", idcl)
};
LstCamera.DataSource = GetDataTable("SELECT DISTINCT IdCA,Camera FROM tblCamera WHERE IdCL =@IdCL;", prm);
LstCamera.DataBind();
}
an image of the displayed data


Marius VasilePosted Nov 17, 2024, 10:10 AM
Thank you Jignesh, for the first example may be a solution if the data is similar but I don't have Unitatea 1 , Unitatea 2 all over I all have Pavilion A, Building C and so on
Jignesh KumarPosted Nov 17, 2024, 10:02 AM
Marius VasilePosted Nov 17, 2024, 9:51 AM
If I add