asp.net gridview与VB.net函数不同步 [英] asp.net gridview out of sync with VB.net function

查看:69
本文介绍了asp.net gridview与VB.net函数不同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



简单的asp.net网页,我通过使用下拉框过滤查询将数据加载到gridview中。这都是在asp.net方面。在VB.net方面,我根据数据网格中的值更改文本框的背景颜色。



问题



我的文本框着色结果总是落后1个事件。每当我更改下拉列表以刷新datagrid中的结果时,我的文本框阴影反映了gridview的最后状态而不是当前状态。



Hello,

simple asp.net webpage in which I am loading data into a gridview by filtering the query with a dropdown box. This is all on the asp.net side. On the VB.net side I am changing the background color of text boxes based on the value in the datagrid.

PROBLEM

My results with text box shading is always 1 event behind. Every-time I change the dropdown list to refresh the result in the datagrid my text box shading reflects the last state of the gridview not the current state.

Public Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles DropDownList1.SelectedIndexChanged

       Try
           If GridView1.Rows(0).Cells(3).Text = "Yes" Then TextBox2.BackColor = Drawing.Color.LightGreen Else TextBox2.BackColor = Drawing.Color.LightSalmon

推荐答案

可能你缺少设置AutoPostBack [ ^ ]



将此添加到下拉列表标记 -

Probably you are missing to set AutoPostBack[^]

add this to the dropdownlist markup-
AutoPostBack="True"





示例:



Example:

<asp:dropdownlist xmlns:asp="#unknown">
             ID="DropDownList1"
             runat="server"
             AutoPostBack="true"
</asp:dropdownlist>





希望,它帮助:)



Hope, it helps :)


确实启用了autopostback并且gridview正确更新但是我上面发布的文本框背景查询不同步并且总是落后1个事件。
autopostback is indeed enabled and the gridview updates correctly however the textbox background query which I posted above is not in sync and is always 1 event behind.


这篇关于asp.net gridview与VB.net函数不同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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