私はasp.netでgridviewとUpdatePanelを使用しています。
<asp:UpdatePanel ID="upSubject" runat="server">
<ContentTemplate>
<div class="c_box" style="height: auto; text-align: center; margin-top: 10px; width:565px; padding-right:140px;">
<asp:GridView ID="gvSubject" runat="server" AutoGenerateColumns="False"
SkinID="gvSubject" ShowHeader="true" ShowHeaderWhenEmpty="true"
onrowcommand="gvSubject_RowCommand">
<Columns>
<asp:BoundField DataField="lblCounter" HeaderText="Number" ReadOnly="True" HeaderStyle-Font-Bold="false" ItemStyle-Width="60px"></asp:BoundField>
<asp:BoundField DataField="lblSubject" HeaderText="Tiltle" ReadOnly="True" HeaderStyle-Font-Bold="false" ItemStyle-Width="300px" ItemStyle-HorizontalAlign="Right"></asp:BoundField>
<asp:TemplateField HeaderText="Delete" ItemStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="false" ItemStyle-Width="60px">
<ItemTemplate>
<asp:ImageButton ID="dltSubject" runat="server" CommandName="remove" CommandArgument="lblCounter" ValidationGroup="Subject" OnClientClick="return confirm('Delete?')" ImageUrl="~/Style/Pic/pic_delete_small.png" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle BackColor="#000000" />
<EmptyDataRowStyle BackColor="#00ff00" />
<EmptyDataTemplate>
Not item...
</EmptyDataTemplate>
</asp:GridView>
</div>
</ContentTemplate>
<Triggers>
<asp:asyncpostbacktrigger controlid="gvSubject" eventname="RowCommand" />
</Triggers>
</asp:UpdatePanel>
また
<asp:asyncpostbacktrigger controlid="dltSubject" eventname="Click" />
.
protected void gvSubject_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "remove")
{
DataTable _dt = (DataTable)Session["Subject"];
_dt.Rows[int.Parse(e.CommandArgument.ToString())].Delete();
gvSubject.DataSource = _dt;
gvSubject.DataBind();
Session["Subject"] = _dt;
}
}
しかし、UpdatePanel は動作しません。UpdatePanel の作業ボタン gridview について教えてください。
グリッドビューと UpdatePanel で ImageButton を動作させたい。