从gridview的下拉列表中删除所选值 [英] Remove selected value from the dropdown list in gridview

查看:92
本文介绍了从gridview的下拉列表中删除所选值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在Gridview中显示数据。在那一列中,有一个下拉列表。用户将从中选择值。我的要求是,如果用户从第一行的下拉列表中选择一个值,它将从第二行下拉列表中删除。如果用户在第二行中选择了另一个值,则第一行和第二行值不应显示在第三行下拉列表中。像这样我想从gridview中的下拉列表中删除已经选择的值。这很紧急。任何人都可以尽快帮助我。

Hi,

I am displaying data in Gridview. In that one column, there is a dropdownlist. user will select value from it. My Requirement is if user select a value from the dropdownlist in the first row, it will be delete from second row dropdown onwards. If the user selected another value in second row, the first and second row values should not display in third row dropdown list onwards. Like this i want to delete already selected value from the dropdownlist in a gridview. Its urgent. Any one can help me ASAP.

推荐答案

你应该在下拉列表的selection_changed事件中创建foreach循环,并在你循环的内部跳过你选择的行。



现在从循环中的下拉列表中选择下拉列表中的值并找到该值的值,然后使用dropdown.removeat(index)调用,它将从该列表中删除。



YOU should create foreach loop inside selection_changed event of dropdown and inside that loop you shoold skip that rows which you selected.

Now take the value from selected dropdown and findindex of that value from dropdown inside loop and then dropdown.removeat(index) call and it will be removed from that list.

protected void dropdown_list_selecteon_changedevent(object a, eventargs e)
{
     Dropdown obj=(Dropdown)a; 
     string value= obj.selectedvale;
     for(int i=0;i<gridview.rows.count;i++)>
     {
          //here you should write code to find selected dropdown index from gridview and skip to execute following code.

         //then find index of value from dropdown which you will find at (i)th row of Gridview.
         //then call dropdown.removeat(i)
      }

}





注意:上面的代码仅用于理解目的,语法可能不正确。所以你应该遵循一个逻辑。



谢谢。



Note: Above code is just for understanding purpose , syntax may not be correct . so you should follow just a logic.

Thanks.


这篇关于从gridview的下拉列表中删除所选值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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