I have a cascaded ListView and I want to reach objects in lvl1 from lvl2
<asp:ListView ID="LV1" runat="server">
<ItemTemplate>
<div class="col-12 p-2 border">
<asp:TextBox ID="txtOID" class="hidden" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"OID")%>' />
<asp:Button ID="BTNObiectiv" runat="server"
Text='<%#Eval("Obiectiv")%>'
OnClick="LV1_Click"
UseSubmitBehavior="false"
Style="font-size: 11px; background-color: lightgreen; width: 200px;" class="btn form-control form-control-sm"
ClientIDMode="Static" />
<div class="row no-gutters">
<div id="DivS" runat="server" class="" clientidmode="Static">
<asp:ListView ID="LV2" runat="server" Visible="false">
<ItemTemplate>
<asp:TextBox ID="txtCID" class="hidden" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"CID")%>' />
<div class="col-12 p-2 border">
<asp:Button ID="BTNCladire" runat="server"
Text='<%#Eval("Cladire")%>'
OnClick="LV2_Click"
UseSubmitBehavior="false"
Style="font-size: 11px; background-color: lightsalmon; width: 180px;" class="btn form-control form-control-sm"
ClientIDMode="Static" />
</div>
In code behind I handle the conection with:
protected void LV1_Click(object sender, EventArgs e)
{
Button cmd = (Button)sender;
ListViewItem ObiectivRow = (ListViewItem)cmd.NamingContainer;
TextBox id = (TextBox)ObiectivRow.FindControl("txtOID");
ListView LstCladire = (ListView)ObiectivRow.FindControl("LV2");
LstCladire.DataSource = null;
LstCladire.DataBind();
int oid = Convert.ToInt32(id.Text);
List<SqlParameter> prm = new List<SqlParameter>
{
new SqlParameter("@OID", oid)
};
LstCladire.DataSource = GetDataTableEvaris("SELECT DISTINCT CID,Cladire FROM tblCladire WHERE OID= @OID;", prm);
LstCladire.DataBind();
if (LstCladire.Visible)
{
LstCladire.Visible = false;
return;
}
LstCladire.Visible = true;
SqlParameter prmS = new SqlParameter("@OID", oid);
hiddenObiectiv.Text = ExecuteScalar("SELECT DISTINCT Obiectiv FROM tblObiectiv WHERE OID= @OID;", prmS);
hiddenObiectiv.Visible = true;
hiddenCladire.Text = string.Empty;
hiddenCota.Text = string.Empty;
hiddenCamera.Text = string.Empty;
}
protected void LV2_Click(object sender, EventArgs e)
{
Button cmd = (Button)sender;
ListViewItem CladireRow = (ListViewItem)cmd.NamingContainer;
TextBox id = (TextBox)CladireRow.FindControl("txtCID");
ListView LstCota = (ListView)CladireRow.FindControl("LV3");
LstCota.DataSource = null;
LstCota.DataBind();
int cid = Convert.ToInt32(id.Text);
List<SqlParameter> prm = new List<SqlParameter>
{
new SqlParameter("@CID", cid)
};
//aici se incarca imaginea pentru cota
LstCota.DataSource = GetDataTableEvaris("SELECT DISTINCT EID,Cota FROM tblCota WHERE CID = @cid;", prm);
LstCota.DataBind();
if (LstCota.Visible)
{
LstCota.Visible = false;
return;
}
LstCota.Visible = true;
SqlParameter prmS = new SqlParameter("@CID", cid);
hiddenCladire.Text = ExecuteScalar("SELECT DISTINCT Cladire FROM tblCladire WHERE CID= @CID;", prmS);
hiddenCladire.Visible = true;
hiddenCota.Text = string.Empty;
hiddenCamera.Text = string.Empty;
}
But I want to disable LstCladire which is in LVL1 from LVL2 procedure on a button click