Detailview页脚模板按钮不可点击

时间:2015-11-26 11:41:41

标签: templates footer

我有detailsview代码,用于更新单个字段的值。更新按钮我保持在页脚模板中。它在Visual Studio中完美运行,如果我发布到服务器并通过Url访问,页脚模板更新按钮是不可点击的。

请建议。

mycode的:     <%@ Page Title =“”Language =“C#”MasterPageFile =“〜/ RedTagMasterPage.master”%>

<script runat="server">

protected void BtnUpdate_Click(object sender, EventArgs e)
{  
    Label lblstatus = (Label)DetailsView1.FindControl("lblUpdateStatus");
    string Vname = DetailsView1.Rows[0].Cells[1].Text;
    TextBox NewQADNo = (TextBox)DetailsView1.FindControl("txtbxQADno");

    if (NewQADNo != null)
    {
      System.Data.SqlClient.SqlConnection myConnection;
      System.Data.SqlClient.SqlCommand myCommand;
       using (myConnection = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["MaterialsConnectionString"].ConnectionString))
       {
        string strUpdate = "UPDATE tblVendorMasterRegisteration SET QADVendorNo=" + NewQADNo.Text.Trim() + " Where VendorName ='" + Vname + "'";
        myCommand = new System.Data.SqlClient.SqlCommand(strUpdate, myConnection);
        myConnection.Open();
        myCommand.ExecuteNonQuery();
        myConnection.Close();

        lblstatus.Text ="Updated Successfully.";

        }
    }
    }

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div style="margin-top: 17px">
    &nbsp;<table border="0" cellpadding="0" cellspacing="0" style="width: 98%; position: relative;
        height: 100%">
        <tr>
            <td style="width: 287px; text-align: center">
                <br />
                <span style="font-size: x-large; background-color: activeborder">
                <span style="font-family: 'Cooper Black'">
                <span style="color: #666666; background-color: #FFFFFF">Vendor Master </span>
                <br style="color: #666666; background-color: #FFFFFF" />
                <span style="color: #666666; background-color: #FFFFFF">Display
                    Page</span></span><br style="color: #666666; background-color: #FFFFFF" />
                </span>
                <br />
                <br />
            </td>
            <td>
    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
        CellPadding="4" DataKeyNames="Vendorregno" DataSourceID="SqlDataSource1" ForeColor="#333333"
        GridLines="None" Height="50px" Style="position:relative; text-align: left; top: -41px; left: 14px;" 
                    Width="337px" AllowPaging="True"  >
        <FooterStyle BackColor="#D0D0D0" Font-Bold="True" ForeColor="White" />
        <CommandRowStyle BackColor="#C5BBAF" Font-Bold="True" />
        <RowStyle BackColor="#E3EAEB" />
        <FieldHeaderStyle BackColor="#D0D0D0" Font-Bold="True" />
        <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
        <Fields>
            <asp:BoundField DataField="VendorName" HeaderText="VendorName" SortExpression="VendorName" />
            <asp:BoundField DataField="VendorAddress" HeaderText="VendorAddress" SortExpression="VendorAddress" />
            <asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
            <asp:BoundField DataField="OfficePhone1" HeaderText="OfficePhone1" SortExpression="OfficePhone1" />
            <asp:BoundField DataField="OfficePhone2" HeaderText="OfficePhone2" SortExpression="OfficePhone2" />
            <asp:BoundField DataField="CellNo" HeaderText="CellNo" SortExpression="CellNo" />
            <asp:BoundField DataField="FaxNo" HeaderText="FaxNo" SortExpression="FaxNo" />
            <asp:BoundField DataField="TempVendor" HeaderText="TempVendor" SortExpression="TempVendor" />
            <asp:BoundField DataField="OperatingDiv" HeaderText="OperatingDiv" SortExpression="OperatingDiv" />
            <asp:BoundField DataField="ContactPersonName" HeaderText="ContactPersonName" SortExpression="ContactPersonName" />
            <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
            <asp:BoundField DataField="Currency" HeaderText="Currency" SortExpression="Currency" />
            <asp:BoundField DataField="Freight" HeaderText="Freight" SortExpression="Freight" />
            <asp:BoundField DataField="PANNo" HeaderText="PANNo" SortExpression="PANNo" />
            <asp:BoundField DataField="ServiceTaxNo" HeaderText="ServiceTaxNo" SortExpression="ServiceTaxNo" />
            <asp:BoundField DataField="CSTNo" HeaderText="CSTNo" SortExpression="CSTNo" />
            <asp:BoundField DataField="TinNo" HeaderText="TinNo" SortExpression="TinNo" />
            <asp:BoundField DataField="ApplierID" HeaderText="ApplierID" SortExpression="ApplierID" />
            <asp:BoundField DataField="ApplierName" HeaderText="ApplierName" SortExpression="ApplierName" />
            <asp:BoundField DataField="Vendorregno" HeaderText="Vendorregno" InsertVisible="False"
                ReadOnly="True" SortExpression="Vendorregno" />
            <asp:TemplateField HeaderText="QADVendorNo">
                <ItemTemplate>

                    <asp:TextBox ID="txtbxQADno" Text='<%# Bind("QADVendorNo") %>' runat="server"></asp:TextBox>

                </ItemTemplate>
            </asp:TemplateField>
        </Fields>
        <FooterTemplate>
            <asp:Button ID="BtnUpdate" runat="server" OnClick="BtnUpdate_Click" Text="Update" ViewStateMode="Enabled" />
             <asp:Label ID="lblUpdateStatus" runat="server" ForeColor="#663300" BackColor="#FFFFCC"></asp:Label>
        </FooterTemplate>
        <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#7C6F57" />
        <AlternatingRowStyle BackColor="White" />
    </asp:DetailsView>
            </td>
        </tr>
    </table>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MaterialsConnectionString %>"
        SelectCommand="SELECT * FROM [tblVendorMasterRegisteration] WHERE  (MaterialsMgrApprovedDate BETWEEN GETDATE() - 30 AND GETDATE())"></asp:SqlDataSource>
    <br />
    <br />
    <br />
    </div>
</asp:Content>

1 个答案:

答案 0 :(得分:0)

深入思考后,我开始知道风格定位给出了问题。 Detailsview Style =“position:relative; to Style =”position:center;