asp.net 3.5中的datalist [英] datalist in asp.net 3.5

查看:61
本文介绍了asp.net 3.5中的datalist的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在按钮上访问数据列表DataListCommandEventArgs单击

how to access data list DataListCommandEventArgs on button click

推荐答案

所有事件处理程序都有两个参数:

1)An object 名为 sender ,它是发起事件的类实例。例如,在Button.Click处理程序中, sender 将是用户单击的按钮。

2) EventArgs (或派生)类实例,名为 e ,它包含事件参数(如果有)。通常,如果这是派生的EventArgs类,那么事件将被声明为将派生类作为参数而不是标准的默认EventArgs,但是您可以将EventArgs转换为派生类并检查它是否有效:

All event handlers have two parameters:
1) An object called sender which is the class instance which originated the event. For example, in a Button.Click handler, sender would be the button the user clicked.
2) An EventArgs (or derived) class instance called e which holds the event arguments if any. Normally, if this is a derived EventArgs class, then the event will be declared as having the derived class as a parameter instead of the standard default EventArgs, but you can cast the EventArgs to a derived class and check if it is valid:
void mySource_Event(object sender, EventArgs e)
   {
   MyEventArgs args = e as MyEventArgs;
   if (args != null)
      {
      // You can use args here.
      }
   }

在VB中可能是这样的:

In VB is would be something like:

Private Sub mySource_Event(sender As Object, e As EventArgs) Handles ...
    Dim args As MyEventArgs = TryCast(e, MyEventArgs)
    If args IsNot Nothing Then
        ' You can use args here.
    End If
End Sub


这篇关于asp.net 3.5中的datalist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆