GridView中的DropDownList“Flashes”当项目被选中并恢复时 [英] DropDownList in GridView "Flashes" when item selected and reverts

查看:60
本文介绍了GridView中的DropDownList“Flashes”当项目被选中并恢复时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我偶然发现了一个奇怪的问题。我有一个带有sevEral列的GridView,其中两个列有下拉列表。其中一个下拉列表按预期工作,另一个下拉列表显示选定的值,然后恢复为其他值。



令人感到奇怪的是它适用于下拉列表中列出的10个值中的2个。

在列模板中,我将文本框与下拉列表一起包含在内,但我认为这不是问题。我在SelectedIndexChange中添加了一个断点,当它到达SelectedIndexChange时,该值已经被更改。



这是标记的一部分:

Hello Everyone, I have stumbled into a strange issue. I have a GridView with sevEral Columns, two of those Columns have dropdowns. One of the dropdowns works as expected, the other shows the selected value for a second and then reverts to something else.

What makes it strange is that it works fine for 2 out of the 10 values listed in the dropdown.
In the Column template I included a textbox together with the dropdown, but I don't think this will be the issue. I added a break point to the SelectedIndexChange, and by the time it hits the SelectedIndexChange the value has already being changed.

This is a portion of the markup:

<asp:TemplateField FooterText="cCommentDesc" HeaderText="cCommentDesc"  SortExpression="cCommentDesc">
                    <ItemTemplate>
                        <asp:TextBox ID="txtComment" runat="server" Width="200px"

                            Text = '<%# Eval("cComment") %>'

                            ReadOnly="True">
                        </asp:TextBox>

                     <asp:DropDownList

                        ID="cboComment"

                        runat="server"

                        DataSourceID = "SQLCommentsDataSource"

                        DataTextField="cCommentDesc"

                        DataValueField="cRtnVal"

                        OnSelectedIndexChanged="cboComment_SelectedIndexChanged"

                        AutoPostBack="True"

                        Width="100px"

                        style="margin-left: 0px;">
                     </asp:DropDownList>

                    </ItemTemplate>

</asp:TemplateField>







SQLCommentsDataSource定义为:






SQLCommentsDataSource is defined as:

SELECT TOP 1 NULL AS cCommentDesc, NULL AS cRtnVal, 0 As nOrder
                           FROM DropDownsValues 
                           UNION
                           SELECT cValue AS cCommentDesc, cRtnVal, nOrder
                           FROM DropDownsValues
                           WHERE cKeyName = 'ServerComments'
                           ORDER BY nOrder 





提前谢谢。



Luis



Thank you in advance.

Luis

推荐答案

我找到了根的问题,但不知道如何继续。在上面的select语句中,cRtnVal列仅包含两个值Yes或No。十个值中有三个是

是而其余的是否。当DataValueField有重复时,每次都会选择列表中的第一个值。我可以通过强制值来区分附加序号然后使用LEFT(cRtnVal,...),但为什么?







有什么建议吗?



谢谢,
I found the root of the problem, but don't know exactly how to proceed. In the select statement above the cRtnVal column only contains two values "Yes" or "No". out of the ten values three are
Yes" and the rest are "No". When the DataValueField has duplicates the first value in the list is selected every time. I can force the values to be distinct by appending a sequential number and then use LEFT(cRtnVal,...) , but why?



Any suggestions?

Thank you,


这篇关于GridView中的DropDownList“Flashes”当项目被选中并恢复时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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