【发布时间】:2014-10-25 08:12:40
【问题描述】:
我在 Gridview 中有一个 LinkButton,它会弹出一个 jQuery 弹出框以确认删除。此外,我还触发了 Gridview RowCommand,它应该为 jQuery 弹出框中的文本框赋值。这里的问题是在单击 LinkButton 后会出现弹出框,但 RowCommand 事件没有为文本框赋值。事实上,文本框恢复到原来的默认值。
我在谷歌上搜索了太多这个问题,但找不到正确的解决方案。以下是我的代码,任何帮助都非常可观。
//The code behind GridView_RowCommand event
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
string arguments = e.CommandName + " - " + e.CommandArgument.ToString() + " - " + e.CommandSource.ToString();
if (e.CommandName == "Delete")
{
txt.Text = e.CommandArgument.ToString();
}
}
//Page Source
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div id="myModal" class="reveal-modal">
<h1>Delete</h1>
<p>This will guide you through the delete process</p>
<asp:TextBox ID="txt" runat="server"></asp:TextBox>
<p><asp:Button ID="Button2" runat="server" Text="Button" /></p>
<a class="close-reveal-modal">×</a>
</div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="RBUEntityDataSource" CssClass="gridview" OnRowCommand="GridView1_RowCommand" EnableViewState="True">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True" SortExpression="Id" />
<asp:BoundField DataField="Region" HeaderText="Region" ReadOnly="True" SortExpression="Region" />
<asp:TemplateField HeaderText="Update">
<ItemTemplate>
<asp:LinkButton ID="lbUpdate" runat="server" CommandName="Update" OnClick="lbUpdate_Click">Update</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="lbDelete" class="big-link" data-reveal-id="myModal" runat="server" CommandName="Delete" CommandArgument='<%# Eval("Id") %>'>Delete</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:EntityDataSource ID="RBUEntityDataSource" runat="server" ConnectionString="name=ChemonicsDBEntities" DefaultContainerName="ChemonicsDBEntities" EnableFlattening="False" EntitySetName="RegionalBusinessUnits" Select="it.[Id], it.[Region]" OrderBy="it.[Id] asc" Where="it.[DeletedBy] = 0">
</asp:EntityDataSource>
</ContentTemplate>
</asp:UpdatePanel>
【问题讨论】:
-
@HassanNisar 怎么做。你能指导我吗?
标签: c# javascript jquery asp.net gridview