`
qq125922714
  • 浏览: 36067 次
社区版块
存档分类
最新评论

[转]raising an event from checkbox in a gridview (gridview中模板表的checkbox的后台事件处理)

    博客分类:
  • java
阅读更多
    <p><span style="font-size: 10pt;">本文转自:http://www.dotnetspider.com/resources/30842-raising-an-event-from-checkbox-in-a-gridview.aspx</span><br><span style="font-size: 10pt;">原文如下:</span></p><p><span style="font-size: 10pt;">description:</span><br><span style="font-size: 10pt;">raising an event from a gridview check box or dropdown list.</span><br><span style="font-size: 10pt;">in case of button or link button then event raises and rowcommand.</span><br><span style="font-size: 10pt;">incase of raising event from a control like checkbox or radiobuttonor dropdownlist or etc event bubbling.</span></p><p><span style="font-size: 10pt;">design view:</span><br><span style="font-size: 10pt;">&lt;asp:gridview id="grdquestions" autogeneratecolumns="false" runat="server" width="698px" &gt;</span><br><span style="font-size: 10pt;"> &lt;headerstyle horizontalalign="left" cssclass="gridheader" / &gt; </span><br><span style="font-size: 10pt;"> &lt;rowstyle cssclass="gridrowstyle" horizontalalign="left" / &gt;</span><br><span style="font-size: 10pt;"> &lt;alternatingrowstyle cssclass="gridalternaterowstyle" / &gt;</span><br><span style="font-size: 10pt;"> &lt; columns &gt;</span><br><span style="font-size: 10pt;"> &lt;asp:templatefield headertext="edit" &gt; </span><br><span style="font-size: 10pt;"> &lt;itemstyle horizontalalign="center" width="50px" &gt;&lt;/itemstyle &gt; </span><br><span style="font-size: 10pt;"> &lt;itemtemplate&gt;</span><br><span style="font-size: 10pt;"> &lt;asp:checkbox id="chkstatus" autopostback="true" runat="server" oncheckedchanged="chkstatus_changed" &gt;&lt;/asp:checkbox&gt; </span></p><p><span style="font-size: 10pt;">  &lt;/itemtemplate&gt; </span><br><span style="font-size: 10pt;"> &lt;/asp:templatefield&gt;</span><br><span style="font-size: 10pt;"> &lt;asp:templatefield headertext="batchpriority"&gt; </span><br><span style="font-size: 10pt;"> &lt;headerstyle wrap="false"&gt;&lt; /headerstyle&gt; </span><br><span style="font-size: 10pt;"> &lt;itemstyle wrap="false"&gt;&lt; /itemstyle&gt; </span><br><span style="font-size: 10pt;"> &lt;itemtemplate&gt; </span><br><span style="font-size: 10pt;"> &lt;asp:dropdownlist id="ddlbatchpriorty" runat="server" width="92px" cssclass="text" &gt;&lt;/asp:dropdownlist&gt;</span><br><span style="font-size: 10pt;"> &lt;/itemtemplate&gt; </span><br><span style="font-size: 10pt;"> &lt;/asp:templatefield&gt;</span><br><span style="font-size: 10pt;"> &lt;columns&gt;</span><br><span style="font-size: 10pt;">&lt;/asp:gridview&gt;</span></p><p><span style="font-size: 10pt;">code behind:</span></p><p><span style="font-size: 10pt;">public void chkstatus_changed(object sender, system.eventargs e)</span><br><span style="font-size: 10pt;">{ </span><br><span style="font-size: 10pt;"> //......when gridview checkbox calls event, then it raises an event. </span><br><span style="font-size: 10pt;"> checkbox chkbox = (checkbox)(sender); </span><br><span style="font-size: 10pt;"> //......sender is converted to checkbox and getting its gridview row by using chkbox.parent.parent. </span><br><span style="font-size: 10pt;"> gridviewrow dg = (gridviewrow)(chkbox.parent.parent);</span><br><span style="font-size: 10pt;"> //......gridview row to find the control or text of particular cell. </span><br><span style="font-size: 10pt;"> dropdownlist ddl = (dropdownlist)(dg.cells[4].findcontrol("ddlbatchpriorty"));</span><br><span style="font-size: 10pt;">}</span></p> 
分享到:
评论

相关推荐

    主持人委托事件

    7. **引发事件(Raising an Event)**:事件发布者使用`OnEventName()`(或类似)的实例方法来触发事件,这个方法通常由`protected virtual`修饰,允许子类覆盖。内部,它会检查是否有订阅者,并调用相应的事件处理...

    NET事件小实例

    4. **引发事件(Raising an Event)**:当类中的某个条件满足时,可以使用`OnEventName`(如`OnPropertyChanged`)这样的标准命名约定或直接使用`event`关键字后面的委托来触发事件。例如,`this.myEvent?.Invoke...

    Running Lean: Iterate from Plan A to a Plan That Works

    Ash Maurya takes you through an exacting strategy for achieving a "product/market fit" for your fledgling venture, based on his own experience in building a wide array of products from high-tech to ...

    .net事件分析范例

    - **事件触发(Raising the Event)**:当特定条件满足时,发布者通过调用事件委托来触发事件。 - **事件处理(Event Handling)**:订阅者的方法被调用,执行相应的行为。 4. **匿名方法与Lambda表达式**: - ...

    Maven权威指南 很精典的学习教程,比ANT更好用

    Tim O'Brien (Sonatype, Inc.) , John Casey (Sonatype, Inc.) , Brian Fox (Sonatype, Inc.) , Bruce Snyder () , Jason Van Zyl (Sonatype, Inc.) , Juven Xu () Abstract Maven权威指南是一本关于Apache Maven...

    .net自定义事件编程

    3. **事件触发(Raising the Event)** - 当需要触发事件时,通常在类的内部通过调用委托实例来完成。例如: ```csharp private void SomeMethod() { if (_myEvent != null) { _myEvent(this, EventArgs....

    c#中委托和事件例子

    在C#编程语言中,委托和事件是两个非常重要的概念,它们主要用于实现对象之间的通信,尤其是在处理异步操作和响应用户界面(UI)交互时。本文将深入探讨这两个概念,并通过一个实例来帮助理解它们的工作原理。 首先...

    程序运行日志处理解决方案

    - **Populating and Raising Events from Code**:在代码中动态生成和触发事件,通过`Trace`类发送日志消息,然后由`Trace Listeners`接收并处理。 - **Populating a log message with additional context ...

    Matlab锁相环路代码phaselockedloopPLL-pll.m

    automatically raising or lowering the frequency of a controlled oscillator until it is matched to the reference in both frequency and phase. A phase-locked loop is an example of a control system ...

    C#中,事件应用的小DEMO

    在C#编程中,事件是实现...以上就是关于C#中事件应用的基本知识,结合给出的DEMO,你将能构建一个简单的系统,模拟汽车防盗器在检测到汽车启动时发出警告。这个DEMO有助于理解事件的工作原理及其在实际项目中的应用。

    unidac64src 6.4.15

    Bug with raising 'Argument out of range' error on TCRDBGrid creating in RAD Studio Berlin with Update 1 is fixed Bug with QueryRecCount when ORDER clause contains CASE..END is fixed Bug with ...

    Agile模型驱动开发BorCon China- Raising the level

    在"Agile模型驱动开发BorCon China- Raising the level"这个主题中,我们探讨的是如何在中国的IT环境中提升Agile MDD的实践水平。 Agile开发,源自2001年的敏捷宣言,强调快速响应变化、团队协作和客户满意度。它的...

    C#委托&事件&实例

    在C#编程语言中,委托和事件是两个关键特性,它们是实现面向对象设计模式,尤其是事件驱动编程的基础。本文将深入探讨这两个概念,并通过实例来帮助你更好地理解和掌握它们。 **1. 委托(Delegate)** 委托在C#中...

    Delphi EurekaLog

    EurekaLog is an add-in tool that gives your application (GUI, Console, Web, etc.) the ability to catch all exceptions, even those raised by memory leaks, and generate a detailed log of the call stack ...

    【高考专题辅导】安徽省2014版高考英语 专题检测卷(三十二)书面表达

    To cultivate a healthy financial mindset, students should be taught financial literacy from an early age. They can be given a budget to manage their expenses, promoting the practice of saving and ...

    我国节能与新能源汽车发展战略与对策 (1).pdf

    This article by Song Pengchao from Yantai Engineering Vocational Technology College in Shandong Province, China, analyzes the strategies and countermeasures for the development of energy-saving and ...

    Metasploit Bootcamp

    He is an M.tech in Computer Sciences and a thought leader who has contributed to raising the bar of understanding on cyber safety and ethical hacking among students of many colleges and universities ...

    Unite Europe 2017 - Squeezing Unity: Tips for raising performance

    Unite Europe 2017 - Squeezing Unity: Tips for raising performance 就是关于如何提升性能的 YouTube 对应的 https://www.youtube.com/watch?v=_wxitgdx-UI&index=7&list=PLX2vGYjWbI0Rzo8D-vUCFVb_hHGxXWd9j

    Event-Aggregator:在一个平台上查找大学校园中发生的所有事件! :calendar::raising_hands:

    事件聚合器 您是否想知道整个大学校园内发生的... 向您展示Event Aggregator,这是您想注册某个事件的所有时间的解决方案,但由于您不了解而无法提供 :sparkles: 技术栈 HTML CSS PHP MySQL 引导程序 项目负责人

Global site tag (gtag.js) - Google Analytics