0
我有詳細視圖代碼,它更新單個字段的值。更新按鈕我保留在頁腳模板中。它在Visual Studio中完美工作,如果我發佈到服務器並通過Url訪問,頁腳模板Update按鈕不可點擊。Detailview頁腳模板按鈕不可點擊
請建議。
mycode的: <%@頁標題= 「」 語言= 「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">
<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>