C# 委托事件处理程序 SelectedIndexChanged
我想将另一个值传递给 LeCmb_Statut_SelectedIndexChanged 方法,我该如何继续?
我有代码:
SqlDataReader reader = comm.ExecuteReader();
while (reader.Read())
{
...
DropDownList LeCmb_Statut = new DropDownList();
string tempLabel = reader["LIBELLE"].ToString();
string templabelVeh = reader["LIBVEH"].ToString()
}
如何将这些临时变量传递到 LeCmb_Statut_SelectedIndexChanged
中?
LeCmb_Statut.SelectedIndexChanged += new EventHandler(LeCmb_Statut_SelectedIndexChanged);
I want to pass another value to the method LeCmb_Statut_SelectedIndexChanged, how can I proceed?
I have the code:
SqlDataReader reader = comm.ExecuteReader();
while (reader.Read())
{
...
DropDownList LeCmb_Statut = new DropDownList();
string tempLabel = reader["LIBELLE"].ToString();
string templabelVeh = reader["LIBVEH"].ToString()
}
How can I pass these temp variables into LeCmb_Statut_SelectedIndexChanged
?
LeCmb_Statut.SelectedIndexChanged += new EventHandler(LeCmb_Statut_SelectedIndexChanged);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用下拉列表的 Tag 属性。
首先,创建一个简单的 DTO:
然后:
然后在 LeCmb_Statut_SelectedIndexChanged 内部:
You could use the Tag property of dropdownlist.
first, create a simple DTO:
then:
then inside the LeCmb_Statut_SelectedIndexChanged:
您可以使用匿名方法来捕获它们:
对于小块或较长的代码,这可以是内联的 - 只需传递给方法:
或者如果您需要发送者/参数:
或者在 C# 3.0 中:
You can use an anonymous method to capture them:
this could be inline for small blocks, or for longer code - just pass to a method:
or if you need the sender/args:
or in C# 3.0: