GridView中的下拉列表问题 [英] Issue with dropdownlist inside gridView

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

问题描述

大家好,

我正在ASP.Net& C#项目.
我有一个Gridview,其中包含Dropdownlist作为其列之一,并且在页面上还有其他文本字段,例如Master-Child关系.

我正在将数据从代码隐藏的CS文件绑定到gridview.
在选择网格的行时-数据应填写在页面上的其他字段中.为此,我要在gridview_rowdatabound事件上添加一个JavaScript函数,并将这些值传递给该函数,以便在选择行时-调用该函数,并用相应的数据填充其他文本字段.
但同时,我在选择下拉列表时应填写一个文本框,为此我在下拉列表中调用客户端功能.

现在我在这种情况下面临问题:
假设我有txtDate,DropDwonName,GridRowSelected

1.选择行时-GridRowSelected
函数被调用,并且根据数据库值填充包含"txtDate"的字段

2.当我从下拉列表中选择值时-它调用其onchange方法并设置"txtDate"字段的值.

但同时,还会调用GridRowSelected函数,该函数与"txtDate"字段中的值重叠(当在选择下拉列表时自动填充该函数时).

在这种情况下,有人可以帮助我吗?非常紧急.

谢谢&问候,
解决方案

一种解决方法是维护一个标志,以检查GridRowSelected函数是否通过下拉更改事件填充了文本框值.并且如果通过下拉事件设置了值,则不要从gridrowselected事件中覆盖.


skantg,

非常感谢.
其实我也在尝试设置Flag,但是由于劳累和压力,我以错误的方式进行操作.
但是今天您向我展示了相同的方向,我在5分钟内完成了该操作.

非常感谢,
阿努


Hi All,

I am working in ASP.Net & c# project.
I have one Gridview which contains the Dropdownlist as one of its column and I have other text fields on the page which are like Master-Child relation.

I am binding data to gridview from code-behind cs file.
On row selection of the grid - the data should be filled in other fields on the page. For this purpose, i m adding one JavaScript function on gridview_rowdatabound event and passing those values in the function so that when row is selected - that function is called and other text fields are filled with corresponding data.
But at the same time, i have one text box which should be filled on selection of dropdownlist and for that i am calling client side function onchange of dropdownlist.

Now I m facing issue in this scenario:
Suppose i have txtDate, DropDwonName,GridRowSelected

1. when row is selected -GridRowSelected
function is called and fields including ''txtDate'' are filled as per database values

2. when i select value from dropdownlist - it calls its onchange method and set the value of ''txtDate'' field.

but at the same time,GridRowSelected function is also getting called which overlaps the value in ''txtDate'' field(when its auto filled on selection of dropdown).

Can anyone help me in this case? Its very urgent.

Thanks & Regards,
anu

解决方案

a workaround is to maintain a flag to check in GridRowSelected function that whether textbox value is filled in through the dropdown change event or not. and in case value is set through dropdown event then don''t override from gridrowselected event.


Hi skantg,

Thanks a lot.
Actually I was also trying to set Flag but due to overwork & stress, i was doing it in wrong way.
But today you showed me same direction & i completed it in 5 min.

Thanks a lot,
Anu


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

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