如何使用findcontrol? [英] How to use findcontrol ?

查看:65
本文介绍了如何使用findcontrol?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带图像的数据列表以及项目模板中的按钮控件'addtocart'。

为了停止图像闪烁,我已将此按钮单独放在更新面板中。

当我点击这个'addtocart'按钮时,我希望'button Checkout'启用为true。

这个'Checkout'按钮位于该datalist的页脚模板中。问题是没有启用结帐按钮。请指导我。



I have a datalist with images alongwith a button control 'addtocart' within item template.
In order to stop image flickering, I have put this button alone inside update panel.
When I click this 'addtocart' button , I want 'button Checkout' to be enabled true.
This 'Checkout' button is inside footer template of that datalist. The problem is that the 'checkout' button is not getting enabled. Please guide me.

<asp:UpdatePanel ID="dd" runat="server"  >
   <ContentTemplate>
         <asp:Button ID="AddToCart"  runat = "server" Text='Add to Cart'   BackColor="DarkSlateBlue" Width="100px"  Style=" font-family:Arial" ForeColor="White" commandname="myevent">
    </asp:Button>
    </ContentTemplate>
    </asp:UpdatePanel>
    </p>
    </td>
    </tr>
    </table>
    </ItemTemplate>
<FooterStyle  BackColor="AliceBlue"  />
<FooterTemplate>
<br />
    <asp:Button ID="BtnCheckOut"  runat = "server" Text='Checkout'   Enabled="false"

    Width="100px"  onclick="CheckOutBtn_Click" style="z-index: 1; width:80px;cursor:pointer;
    margin-left:350px ; font-family:Arial;  text-align:center; height:22px;  font-weight:600; " > </asp:Button>
<br />










public void dl_item_command(Object sender, DataListCommandEventArgs e)
  {
      if (e.CommandName == "myevent") // check commandname here
      {
          v_FirstSessionTag = "*";
          Session["FirstSessionTag"] = v_FirstSessionTag;
          Button CheckOutBtn = (Button)DataList1.Controls[DataList1.Controls.Count - 1].FindControl("BtnCheckOut");
          CheckOutBtn.Enabled = true;

推荐答案

Button CheckOutBtn = dd.FindControl("BtnCheckOut") as Button;
CheckOutBtn.Enabled = true;



或者尝试放置断点,看看究竟是什么发生在那边。



-KR


Or else try to put breakpoint and see what is actually happening over there.

-KR


这篇关于如何使用findcontrol?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆