如何将gridview模板列中的checkbox作为updatepanel的Triggers?

fireleopard 2009-03-08 08:35:20
现在页面中有一个updatepanel1,一个gridview1,在gridview1中有个模板列,采用的checkbox1,现在想要点击checkbox,使得updatepanel1能够更新,该如何设置啊?
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate></ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="GridView1"
EventName="SelectedIndexChanging" />
<asp:AsyncPostBackTrigger ControlID="checkbox1" EventName="CheckedChanged" />
</Triggers>
</asp:UpdatePanel>

<asp:GridView ID="GridView1" runat="server">
<HeaderStyle Font-Bold="True" ForeColor="White" Height="24"
HorizontalAlign="Center" VerticalAlign="Middle" CssClass="Freezing"/>
<Columns>
<asp:TemplateField HeaderText="选择" ItemStyle-Width="30" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true" OnCheckedChanged="CheckBox1_CheckedChanged"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

用上面这种方法不行。
...全文
407 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq2013 2009-03-09
  • 打赏
  • 举报
回复
因为你CheckBox1设置了AutoPostBack="true" ,可以试试直接调用UpdatePanel1的Update方法!!

protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
UpdatePanel1.Update();
}
fireleopard 2009-03-09
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 koukoujiayi 的回复:]
因为你CheckBox1设置了AutoPostBack="true" ,可以试试直接调用UpdatePanel1的Update方法!!

protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
UpdatePanel1.Update();
}
[/Quote]

哈哈,有道理,搞定啦!
多谢!!!
koukoujiayi 2009-03-08
  • 打赏
  • 举报
回复
因为你CheckBox1设置了AutoPostBack="true" ,可以试试直接调用UpdatePanel1的Update方法!!

protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
UpdatePanel1.Update();
}
a12321321321312321 2009-03-08
  • 打赏
  • 举报
回复
checkbox的AutoPostBack="True" 在将updatepanel1 设置为ChildrenAsTriggers="True" 。应该可以吧,我猜的呵呵。不能话楼主不要骂我~~
wuyq11 2009-03-08
  • 打赏
  • 举报
回复
在CheckBox1_CheckedChanged里更新数据或通过js异步调用ajax更新数据
CutBug 2009-03-08
  • 打赏
  • 举报
回复
checkbox加个js onclick调用后台ajaxMethod
namhyuk 2009-03-08
  • 打赏
  • 举报
回复
如果是我,可能在GridView.RowDataBound事件里为CheckBox1增加Attribute, 执行一个js.
用js来更新UpdatePanel,var prm = Sys.WebForms.WebRequestManager.getInstance(); prm.Update('UpdatePanel1', null);

具体代码忘了,差不多这样。

62,268

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧