将值传递给方法并保存在数组中 [英] pass the values to method and save in array

查看:83
本文介绍了将值传递给方法并保存在数组中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮我解决这个问题.我在asp.net中有三个下拉菜单.我想当我从下拉列表中选择项目并单击一个按钮时,以便将选定的项目传递给另一个名为passedvalues的数学方法,在该方法中,应该有三个不同的数组来保存那些选定的下拉菜单的项目. "h2_lin">解决方案

在您的click事件中,调用将三个参数作为每个ddl的selecteditem的方法,然后将每个参数添加到所需的数组中.

类似的东西

 btnGetSelectedValues_Click(对象发​​件人,EventArgs e)
{
  passValues(ddl1.SelectedIndex,ddl2.SelectedIndex,ddl3.SelectedIndex);
} 



  void  PassedValues(intddlvalue1, int  ddlvalue2,// 创建阵列
  array1.添加(ddlvalue1);
  array2.添加(ddlvalue2);
  array3.添加(ddlvalue3);
} 



可能存在一些语法问题,但我认为您可以理解.


hi please help me to solve this problem.i have three dropdowns in asp.net. i want to that when i select the items from dropdowns and click a button so the selected items should be passed to another mathod named passedvalues and in that method there shuld be three different arrays that save the items of those selected dropdowns.

解决方案

In your click event call the method which takes three arguments as selecteditems for each ddl then add each argument to array that you need.

something like;

btnGetSelectedValues_Click(object sender, EventArgs e)
{
  passedValues(ddl1.SelectedIndex, ddl2.SelectedIndex, ddl3.SelectedIndex);
}



void passedValues(intddlvalue1, int ddlvalue2, int ddlvalue3)
{
  //create your arrays
  array1.add(ddlvalue1);
  array2.add(ddlvalue2);
  array3.add(ddlvalue3);
}



there might be some syntax problems problems but i think you get the idea.


这篇关于将值传递给方法并保存在数组中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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