如何从面板

时间:2015-08-14 08:03:48

标签: c# asp.net panel

我是ASP.NET新手。我采取了Panel。在Panel里面,我已经拿了一张桌子。表格内有TextBoxRadioButtonButton控件。

我在button_click事件中编写了一些代码。 但没有任何反应。 button_click事件未触发。 现在该怎么办?

我还有一些其他的东西在面板中。但没有点击事件正在发挥作用。

代码如下:

<asp:Panel ID="Pnlproducts" runat="server" ScrollBars="Auto" Height="500px" BorderColor="Black" BorderStyle="Inset" BorderWidth="1px">
    <asp:DataList ID="DLProducts" runat="server" RepeatColumns="3" Width="600px" OnSelectedIndexChanged="DLProducts_SelectedIndexChanged">
        <ItemTemplate >
            <table align="left" class="auto-style6" style="border-color:#9900FF;border-left:1px;border-right:1px;border-top:1px;">
            <tr>
                <td style="border-color: #000000; border-width: 1px; border-bottom-style: ridge" class="auto-style8">
                    <asp:Label ID="lblProductName" runat="server" Text="<%# Bind('ProductName') %>" Font-Bold="True"></asp:Label>
                </td>
            </tr>
            <tr>
                <td class="auto-style9">
                    <asp:Image ID="Image2" runat="server" Height="160px" ImageUrl="<%# Bind('ProductImage') %>" Width="173px" Style="border:ridge 1px black" />
                </td>
            </tr>
            <tr>
                <td class="auto-style9"><strong>Price:</strong><asp:Label ID="lblPrice" runat="server" Text="<%# Bind('ProductPrice') %>" Font-Bold="True" ForeColor="Red"></asp:Label>
                </td>
            </tr>
            <tr>
                <td class="auto-style9">
                    <asp:Button ID="Addtocartbtn" runat="server" BorderStyle="Solid" BorderWidth="1px" OnClick="Addtocartbtn_Click" Text="Add to Cart" Width="170px" BorderColor="Black" />
                </td>
            </tr>
            </table>
        </ItemTemplate>
    </asp:DataList>                     
</asp:Panel>
<asp:Panel ID="Panel111" runat="server" ScrollBars="Auto" Height="500px" BorderColor="Black" BorderStyle="Inset" BorderWidth="1px">
    <table class="auto-style16">
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
    </table>
</asp:Panel>
</td>

<td>
    <asp:Panel ID="pnlCatagory" runat="server" Height="500px" ScrollBars="Auto" BorderColor="Black" BorderStyle="Inset" BorderWidth="1px">

        <div class="auto-style7">
            <asp:DataList ID="dlCatagory" runat="server" BackColor="White" BorderColor="#CCCCCC" BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Horizontal">
                <FooterStyle BackColor="#CCCC99" ForeColor="Black" />
                <HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
                <ItemTemplate>
                    <asp:LinkButton ID="LBTNCatagoty" runat="server" CommandArgument="<%# Bind('CatagoryID') %>" Font-Bold="True" OnClick="LBTNCatagoty_Click" Text="<%# Bind('CatagoryName') %>"></asp:LinkButton>
                </ItemTemplate>
            </asp:DataList>
        </div>
    </asp:Panel>
                                    <asp:Panel ID="Panel222" runat="server" Height="500px" ScrollBars="Auto" BorderColor="Black" BorderStyle="Inset" BorderWidth="1px">
    <table class="auto-style10">
        <tr>
            <td class="auto-style7" colspan="2"><strong>Please Type Your Details</strong></td>
        </tr>
        <tr>
            <td class="auto-style12"></td>
            <td class="auto-style11"></td>
        </tr>
        <tr>
            <td class="auto-style15">Name :</td>
            <td class="johnykbd8">
               <asp:TextBox ID="TextBoxUserName" runat="server" Width="180px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="auto-style15">E-mail :</td>
            <td class="johnykbd8">
                <asp:TextBox ID="TextBoxEmail" runat="server" Width="180px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="auto-style15">Address:</td>
            <td class="johnykbd8">
                <asp:TextBox ID="TextBoxAdress" runat="server" Height="90px" TextMode="MultiLine" Width="180px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="auto-style15">Gender :</td>
            <td>
                <asp:RadioButton ID="RadioButton1" runat="server" GroupName="GenderGroup" Text="Male" /><br />
          &nbsp;<asp:RadioButton ID="RadioButton2" runat="server" GroupName="GenderGroup" Text="Female" />
            </td>
        </tr>
        <tr>
             <td class="auto-style15">Mobile:</td>
             <td class="johnykbd8">
                 <asp:TextBox ID="TextBoxMobileNum" runat="server" Width="180px"></asp:TextBox>
             </td>
        </tr>
        <tr>
            <td class="auto-style15">Photo :</td>
            <td class="johnykbd8">
                <asp:FileUpload ID="FileUploaduserphoto" runat="server" Width="180px" />
            </td>
        </tr>
        <tr>
            <td class="auto-style15">Payment :</td>
            <td>
                <asp:RadioButton ID="RadioButton3" runat="server" GroupName="Paymentgroup" Text="Visa" /><br />
                <asp:RadioButton ID="RadioButton4" runat="server" GroupName="Paymentgroup" Text="MasterCard" /><br />
                <asp:RadioButton ID="RadioButton5" runat="server" GroupName="Paymentgroup" Text="Cash On Delivery" />
            </td>
        </tr>
        <tr>
            <td class="auto-style15">Review :</td>
            <td>
                <asp:TextBox ID="TextBoxreview" runat="server" Width="180px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="auto-style15">Total : </td>
            <td>BDT :<asp:Label ID="Labelshopamount" runat="server"></asp:Label></td>
        </tr>
        <tr>
            <td colspan="2">
                <asp:ImageButton ID="ImageButtonOrderNow" runat="server" ImageUrl="~/Images/Designing/order.jpg" OnClick="ImageButtonOrderNow_Click" Width="250px" />
            </td>
        </tr>
    </table>
</asp:Panel>

1 个答案:

答案 0 :(得分:0)

例如,如果按钮位于datalist或gridview中,请设置CommandName属性。数据绑定对象(datalist,gridview)具有ItemCommand事件。将代码放在此事件中。 伪代码:

if (e.CommandName.equals(your_command_name)){ label1.text = e.CommandArgument };
相关问题