将gridview选中的行值显示为c#中的dropdownlist [英] display gridview selected row value to dropdownlist in c#

查看:114
本文介绍了将gridview选中的行值显示为c#中的dropdownlist的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将gridview选择的行值显示到下拉列表。



我的代码如下

i want to display gridview selected row value to dropdownlist.

for that my code as follows

protected void gvFacdet_SelectedIndexChanged(object sender, EventArgs e)
   {
       txt_name.Text = gvFacdet.SelectedRow.Cells[1].Text.ToString();
       ddldesg.Items.Add(gvFacdet.SelectedRow.Cells[2].Text.ToString());
   }



在gridview行中如下


In gridview row as follows

             Name                 Designation
select       Ramesh               Courseofficer



如下


in run mode as follows

Name                textbox
Designation         dropdownlist





当我选择gridview行值时,gridview选择的行值将显示在相应的文本框和下拉列表中



要显示的文本框名称和要显示的下拉列表名称。



请帮助我什么是我上面的代码中的问题。



When i select the gridview row value that gridview selected row value to be displayed in respective textbox and dropdownlist

In textbox name to be displayed and dropdownlist designation to be displayed.

please help me what is the problem in my above code.

推荐答案

首先制作一个列表。然后在列表中添加项目。然后将列表作为下拉列表的数据源。它将起作用。
First make a list.Then add items in the list.Then make list as data source of drop down.It will work.


在gridview行命令事件中,在选择时获取id并将值设置为textbox以及下拉列表。
In gridview row command event ,get the id when u r selecting and set value to textbox as well as dropdown.


这篇关于将gridview选中的行值显示为c#中的dropdownlist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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