我可以拿我的文本箱更新数据库。 这些变化如所节省(这些变化在网页上得到拯救),而模式的流行则消失,但我试图改变数据库的案文保持不变。
Protected Sub SubmitEdit_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim myControl As Control = FindControl("txtData")
If (Not myControl Is Nothing) Then
Dim UpdateSql As String = "UPDATE Picklist SET (Data) = @Data WHERE PicklistID = @PicklistID"
Using cn As New SqlConnection
(System.Configuration.ConfigurationManager.ConnectionStrings
("LocalSqlServer").ConnectionString)
Using sqlcmd As New SqlCommand(UpdateSql, cn)
sqlcmd.Parameters.Add(New SqlParameter("@Data", myControl))
cn.Open()
sqlcmd.ExecuteNonQuery()
End Using
End Using
Else
End If
End Sub
<asp:TabPanel ID="tab2" runat="server" HeaderText="Descriptions">
<HeaderTemplate>Descriptions</HeaderTemplate>
<ContentTemplate>
<ul class="info">
<asp:ListView ID="lvDescriptions" runat="server"
DataSourceID="dsAdminMarketingDescriptions" DataKeyNames="MarketingID">
<ItemTemplate>
<li class="item">
<asp:LinkButton ID="ViewDescriptionButton" runat="server">
<%# Eval("Title")%>
</asp:LinkButton>
<asp:ImageButton ID="DeleteDescriptionButton" runat="server"
Style="float:right;" AlternateText=""
ImageUrl="../../images/delete.png" CommandName="Delete"
OnClientClick="return confirm( Are you sure you want to delete this
description? )" />
<asp:Panel ID="ViewDescriptionPanel" runat="server"
CssClass="DescModalPopup">
<div class="PopupHeader">View Description -- <%#Eval("Title") %>
<asp:ImageButton ID="CancelDescriptionButton" runat="server"
ImageUrl="../../images/cancel.png" AlternateText=""
Style="float:right;"/>
<asp:ImageButton ID="EditDescriptionButton" runat="server"
ImageUrl="../../images/edit.png" AlternateText=""
Style="float:right;" CommandName="Edit" AutoPostBack="false" />
</div>
<asp:Label ID="Description" runat="server" style="padding:2px;">
<%# Eval("Data")%>
</asp:Label>
</asp:Panel>
<asp:ModalPopupExtender ID="ViewDescriptionModal" runat="server"
BackgroundCssClass="modalBackground" DropShadow="false"
DynamicServicePath="" Enabled="true"
PopupControlID="ViewDescriptionPanel"
TargetControlID="ViewDescriptionButton"
CancelControlID="CancelDescriptionButton"></asp:ModalPopupExtender>
<asp:Panel ID="EditDescriptionPanel" runat="server"
CssClass="DescModalPopup">
<div class="PopupHeader">Edit Description -- <%# Eval("Title")%>
<asp:ImageButton ID="Cancel" runat="server"
ImageUrl="../../images/cancel.png" AlternateText=""
Style="float:right;"/>
</div>
<asp:TextBox ID="txtData" runat="server" TextMode="MultiLine"
Text= <%# Eval("Data")%> >
</asp:TextBox><br />
<asp:Button ID="SubmitEdit" runat="server" Text="Submit" />
<asp:Button ID="CancelEdit" runat="server" Text="Cancel" />
</asp:Panel>
<asp:ModalPopupExtender ID="EditDescriptionModal" runat="server"
BackgroundCssClass="modalBackground" DropShadow="false"
DynamicServicePath="" Enabled="true"
PopupControlID="EditDescriptionPanel"
TargetControlID="EditDescriptionButton">
</asp:ModalPopupExtender>
</li>
</ItemTemplate>
www.un.org/Depts/DGACM/index_spanish.htm UPDATE:我尝试利用一种试图捕获物来获取错误信息,但它的确做了一些工作。
Protected Sub SubmitEdit_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim myControl As Control = FindControl("txtData")
If (Not myControl Is Nothing) Then
Try
Dim UpdateSql As String = "UPDATE Picklist
SET (Data) = @Data
WHERE Title = @Title"
Using cn As New SqlConnection
(System.Configuration.ConfigurationManager.ConnectionStrings
("LocalSqlServer").ConnectionString)
Using sqlcmd As New SqlCommand(UpdateSql, cn)
sqlcmd.Parameters.Add(New SqlParameter("@Data",
DirectCast(myControl, TextBox).Text))
cn.Open()
sqlcmd.ExecuteNonQuery()
End Using
cn.Close()
End Using
Catch ex As Exception
Response.Write(ex.Message())
End Try
Else
End If
Response.Redirect(Request.RawUrl)
End Sub
www.un.org/Depts/DGACM/index_spanish.htm 最新资料:数字不详。 在这里,所有其他法典都保留同样的。
Protected Sub SubmitEdit_Click(ByVal sender As Object, ByVal e As EventArgs)
For Each item As ListViewDataItem In lvDescriptions.Items
Dim txtData As TextBox = DirectCast(item.FindControl("txtData"), TextBox)
Dim ltlTitle As Literal = DirectCast(item.FindControl("ltlTitle"), Literal)
Dim UpdateSql As String = "UPDATE Picklist
SET Data = @Data
WHERE Title = @Title"
Using cn As New SqlConnection
(System.Configuration.ConfigurationManager.ConnectionStrings
("LocalSqlServer").ConnectionString)
Using sqlcmd As New SqlCommand(UpdateSql, cn)
sqlcmd.Parameters.Add(New SqlParameter("@Data", txtData.Text))
sqlcmd.Parameters.Add(New SqlParameter("@Title", ltlTitle.Text))
cn.Open()
sqlcmd.ExecuteNonQuery()
End Using
cn.Close()
End Using
Next
Response.Redirect(Request.RawUrl)
End Sub