更新未在GridView中触发 [英] Update not firing in GridView
问题描述
<我的GridView通过SqlDataSource绑定到我的数据库。我的数据库名称是gsi_swift_audit,主键称为index_n。
使用回发的搜索功能工作正常,我设置了自动生成编辑按钮=真,并且可以点击它给我更新和取消 。取消按钮工作正常,但是当我点击更新时,没有任何内容正在更新到我的数据库中,或者没有任何反应。
这是我的代码 -
.aspx(对于我的select / update命令和更新参数,filter参数适用于我的搜索功能):
<My GridView is binded to my database via SqlDataSource. The name of my database is gsi_swift_audit and has the primary key known as index_n.
The search function using postback is working fine and I have set Auto generate Edit Button = "True" and is able to click that to give me "Update and Cancel". The cancel button works fine, however when I click update, nothing is being updated into my database or rather nothing happens.
Here are my codes -
.aspx (for my select/update command and update parameters, the filter parameter is for my search function):
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server"
AllowPaging="True" AllowSorting="True" AutoGenerateEditButton="True" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderWidth="1px" CellPadding="3" DataSourceID="SqlDataSource1" GridLines="Vertical" DataKeyNames="INDEX_N" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
<AlternatingRowStyle BackColor="#DCDCDC" />
<Columns>
<asp:BoundField DataField="MSG_ID" HeaderText="MSG_ID" SortExpression="MSG_ID" ReadOnly="true"/>
<asp:BoundField DataField="ACTION_IND" HeaderText="ACTION_IND" SortExpression="ACTION_IND" />
<asp:BoundField DataField="ACTION_DATE" HeaderText="ACTION_DATE" SortExpression="ACTION_DATE" />
<asp:BoundField DataField="USERNAME" HeaderText="USERNAME" SortExpression="USERNAME" />
<asp:BoundField DataField="INDEX_N" HeaderText="INDEX_N" ReadOnly="True" SortExpression="INDEX_N" />
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#0000A9" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#000065" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:gsiadmin %>" ProviderName="<%$ ConnectionStrings:gsiadmin.ProviderName %>"
UpdateCommand="UPDATE GSI_SWIFT_AUDIT SET ACTION_IND = @ACTION_IND, ACTION_DATE = @ACTION_DATE, USERNAME = @USERNAME WHERE INDEX_N = @INDEX_N"
SelectCommand="SELECT * FROM "GSI_SWIFT_AUDIT"" FilterExpression="MSG_ID = {0}">
<FilterParameters>
<asp:ControlParameter Name="txtsearchMSGID" ControlID="txtsearchMSGID" PropertyName="Text" />
</FilterParameters>
<UpdateParameters>
<asp:Parameter Name="ACTION_IND" />
<asp:Parameter Name="ACTION_DATE" />
<asp:Parameter Name="USERNAME" />
</UpdateParameters>
</asp:SqlDataSource>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="txtsearchMSGID" EventName="TextChanged" />
<asp:AsyncPostBackTrigger ControlID="GridView1" />
</Triggers>
</asp:UpdatePanel>
我是新手编码所以我希望我能够很快解决这个问题! :)
I'm new to coding so I hope I will be able to solve this soon! :)
推荐答案
ConnectionStrings:gsiadmin%> ProviderName = <%
ConnectionStrings:gsiadmin %>" ProviderName="<%
ConnectionStrings:gsiadmin.ProviderName%>
UpdateCommand = UPDATE GSI_SWIFT_AUDIT SET ACTION_IND = @ACTION_IND,ACTION_DATE = @ACTION_DATE,USERNAME = @USERNAME WHERE INDEX_N = @INDEX_N
SelectCommand = SELECT * FROM GSI_SWIFT_AUDIT FilterExpression = MSG_ID = {0} < span class =code-keyword>>
< FilterParameters>
< asp:ControlParameter Name = txtsearchMSGID ControlID = txtsearchMSGID PropertyName = Text />
< / FilterParameters >
< UpdateParameters>
< asp:参数名称= ACTION_IND />
< asp:参数名称= ACTION_DATE />
< asp:参数名称= USERNAME />
< / UpdateParameters >
< / asp:SqlDataSource >
< / ContentTemplate >
<触发器>
< asp:AsyncPostBackTrigger ControlID = txtsearchMSGID EventName = TextChanged />
< asp:AsyncPostBackTrigger ControlID = GridView1 />
< / 触发器 >
< / asp:UpdatePanel >
ConnectionStrings:gsiadmin.ProviderName %>" UpdateCommand="UPDATE GSI_SWIFT_AUDIT SET ACTION_IND = @ACTION_IND, ACTION_DATE = @ACTION_DATE, USERNAME = @USERNAME WHERE INDEX_N = @INDEX_N" SelectCommand="SELECT * FROM "GSI_SWIFT_AUDIT"" FilterExpression="MSG_ID = {0}"> <FilterParameters> <asp:ControlParameter Name="txtsearchMSGID" ControlID="txtsearchMSGID" PropertyName="Text" /> </FilterParameters> <UpdateParameters> <asp:Parameter Name="ACTION_IND" /> <asp:Parameter Name="ACTION_DATE" /> <asp:Parameter Name="USERNAME" /> </UpdateParameters> </asp:SqlDataSource> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="txtsearchMSGID" EventName="TextChanged" /> <asp:AsyncPostBackTrigger ControlID="GridView1" /> </Triggers> </asp:UpdatePanel>
我是新手编码所以我希望我能够很快解决这个问题! :)
I'm new to coding so I hope I will be able to solve this soon! :)
参考
https://www.asp.net/ajax/documentation/live/tutorials/UsingUpdatePanelControls.aspx [ ^ ]
这篇关于更新未在GridView中触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!