按钮单击事件不会在Tabcontrol中触发

时间:2014-02-16 11:36:12

标签: asp.net

我在ajax选项卡面板中放置了一个文本框,按钮和网格视图。程序将在点击按钮后显示网格视图中的内容。我已经编写了所有代码并且此代码工作正常而不使用选项卡面板,但是当我添加选项卡面板时,按钮点击根本不会触发,请帮助我。

这是我的代码

<ajaxtoolkit:TabPanel ID="pnledit" runat="server" >
<HeaderTemplate>
</HeaderTemplate>
<ContentTemplate>
 <asp:Panel ID="edit" runat="server">
        <div>
        <table style="width:100%;">
            <tr>
                <td style="height:40px; text-align:right;  width:60%">
                     <asp:TextBox ID="txtsearch" runat="server" CssClass="search"             Width="200px" Height="22px"></asp:TextBox>&nbsp&nbsp

                    <asp:DropDownList ID="drpopt" runat="server" Height="24px">
                        <asp:ListItem Selected="True">Voucher No</asp:ListItem>
                        <asp:ListItem>Name</asp:ListItem>
                        <asp:ListItem>Date</asp:ListItem>
                    </asp:DropDownList>&nbsp
                    </td>
                    <td>
                        <asp:ImageButton ID="btGo" runat="server" ImageUrl= "~/images/go.gif"  OnClick="btGo_Click" />
                    </td>
                </tr>
               </table>
               <asp:GridView ID="ReceiptDet" runat="server" 
                AutoGenerateColumns = "False"  AlternatingRowStyle-BackColor = ""  
                HeaderStyle-BackColor = "" AllowPaging ="True" HorizontalAlign="Center" EmptyDataText="No Records Found"
                OnPageIndexChanging = "ReceiptDetPaging" Font-Size="Small"
                PageSize = "20" CellPadding="3" BackColor="White" BorderColor="#CCCCCC" 
                    BorderStyle="None" BorderWidth="1px" DataKeyNames="BTCode" >
                <Columns>
                <asp:BoundField DataField = "BTCode" HeaderText = "Tran Code"  />    
                <asp:BoundField DataField = "BTID" HeaderText = "Tran ID"/> 
                <asp:BoundField DataField = "Vdate" HeaderText = "Tran Date" /> 
                <asp:BoundField DataField = "VNo" HeaderText = "Vouch.No" /> 
                <asp:BoundField DataField = "Name" HeaderText = "Name" /> 
                <asp:BoundField DataField = "Amt" HeaderText = "Receipt Amt" /> 
                <asp:BoundField DataField = "Narr" HeaderText = "Narration" HeaderStyle-Width="200px" /> 
                <asp:BoundField DataField = "TotAmt" HeaderText = "TotAmt" /> 
                 <asp:TemplateField HeaderText="Edit">
                        <ItemTemplate>
                        <asp:ImageButton ID="editbt" ImageUrl="images/edit.jpg" runat="server" Width="25" Height="25" onclick="editbt_Click"  CausesValidation="false"/>
                        </ItemTemplate>
                 </asp:TemplateField>
                  <asp:TemplateField HeaderText="Print">
                        <ItemTemplate>
                        <asp:ImageButton ID="printbt" ImageUrl="images/print.jpg" runat="server" Width="25" Height="25"  CausesValidation="false" />
                        </ItemTemplate>
                  </asp:TemplateField>
                  <asp:TemplateField HeaderText="Delete">
                        <ItemTemplate>
                        <asp:ImageButton ID="deletebt" ImageUrl="images/delete.gif" runat="server" Width="25" Height="25" OnClick="deletebt_Click" CausesValidation="false" />
                        </ItemTemplate>
                  </asp:TemplateField>

                </Columns> 

                <FooterStyle BackColor="White" ForeColor="#000066" />

                <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White"></HeaderStyle>
                    <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                    <RowStyle ForeColor="#000066" />
                    <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                    <SortedAscendingCellStyle BackColor="#F1F1F1" />
                    <SortedAscendingHeaderStyle BackColor="#007DBB" />
                    <SortedDescendingCellStyle BackColor="#CAC9C9" />
                    <SortedDescendingHeaderStyle BackColor="#00547E" />
                </asp:GridView>
        </div>
        </asp:Panel>
        </ContentTemplate>
        </ajaxtoolkit:TabPanel>
        </ajaxtoolkit:TabContainer>

Cs代码

protected void btGo_Click(object sender, ImageClickEventArgs e)
{
    if (drpopt.SelectedIndex == 0)
    {
        var conString = System.Configuration.ConfigurationManager.ConnectionStrings["SQLDbConnection"];
        string strConnString = conString.ConnectionString;
        SqlConnection sqlConnection = new SqlConnection(strConnString);
        SqlCommand sqlCommand = new SqlCommand("proc_bcdetvoucher", sqlConnection);
        sqlCommand.CommandType = CommandType.StoredProcedure;
        sqlConnection.Open();
        sqlCommand.Parameters.Add("@vno", SqlDbType.NVarChar).Value = txtsearch.Text;
        sqlCommand.Parameters.Add("@vtype", SqlDbType.NVarChar).Value = "CR";
        SqlDataAdapter adp = new SqlDataAdapter(sqlCommand);
        DataTable dt = new DataTable();
        adp.Fill(dt);
        ReceiptDet.DataSource = dt;
        ReceiptDet.DataBind();
    }
    else if (drpopt.SelectedIndex == 1)
    {
        var conString = System.Configuration.ConfigurationManager.ConnectionStrings["SQLDbConnection"];
        string strConnString = conString.ConnectionString;
        SqlConnection sqlConnection = new SqlConnection(strConnString);
        SqlCommand sqlCommand = new SqlCommand("proc_bcdetname", sqlConnection);
        sqlCommand.CommandType = CommandType.StoredProcedure;
        sqlConnection.Open();
        sqlCommand.Parameters.Add("@lname", SqlDbType.NVarChar).Value = txtsearch.Text;
        sqlCommand.Parameters.Add("@vtype", SqlDbType.NVarChar).Value = "CR";
        SqlDataAdapter adp = new SqlDataAdapter(sqlCommand);
        DataTable dt = new DataTable();
        adp.Fill(dt);
        ReceiptDet.DataSource = dt;
        ReceiptDet.DataBind();
    }

    else if (drpopt.SelectedIndex == 2)
    {
        var conString = System.Configuration.ConfigurationManager.ConnectionStrings["SQLDbConnection"];
        string strConnString = conString.ConnectionString;
        SqlConnection sqlConnection = new SqlConnection(strConnString);
        SqlCommand sqlCommand = new SqlCommand("proc_bcdetdate", sqlConnection);
        sqlCommand.CommandType = CommandType.StoredProcedure;
        sqlConnection.Open();
        sqlCommand.Parameters.Add("@vdate", SqlDbType.NVarChar).Value = txtsearch.Text;
        sqlCommand.Parameters.Add("@vtype", SqlDbType.NVarChar).Value = "CR";
        SqlDataAdapter adp = new SqlDataAdapter(sqlCommand);
        DataTable dt = new DataTable();
        adp.Fill(dt);
        ReceiptDet.DataSource = dt;
        ReceiptDet.DataBind();
    }

}

0 个答案:

没有答案