当用户在我的数据网格视图中选择一行时,数据网格视图外部的标签不会更新。
正如您在Visual Studio中看到的那样,将捕获所选行的值。但是从视觉上看,它不会更新。
这是我的数据网格代码的样子。
import tkinter as tk
class MainWindow(tk.Frame):
counter = 0
def __init__(self, *args, **kwargs):
tk.Frame.__init__(self, *args, **kwargs)
self.button = tk.Button(self, text="Create new window",
command=self.create_window)
self.button.grid(padx = 5, pady = 5, row = 1, column = 3)
def create_window(self):
height = 2
width = 3
numberA=0
achievs = ["1", "2", "3", "4", "5", "6"]
self.counter += 1
t = tk.Toplevel(self)
t.wm_title("Window #%s" % self.counter)
for i in range(height): #Rows
for j in range(width): #Columns
gridVal = tk.Label(t, text=achievs[numberA], relief=tk.RIDGE)
gridVal.grid(row=i, column=j)
numberA = numberA + 1
if __name__ == "__main__":
root = tk.Tk()
main = MainWindow(root)
main.grid(row=4, column=5, padx=5, pady=25)
root.mainloop()
这是网格外部的标签代码的样子
<asp:UpdatePanel ID="uplPanel" runat="server" >
<ContentTemplate>
<asp:GridView ID="gvInventario" runat="server" AutoGenerateColumns="false" AllowSorting="true" ShowFooter="false" DataKeyNames="componente_id, ubicacion_id, proveedor_id" PageSize="20"
ShowHeaderWhenEmpty="true" AllowPaging="True" OnPageIndexChanging="gridView_PageIndexChanging" OnSelectedIndexChanged="OnSelectedIndexChanged" OnRowDataBound="OnRowDataBound"
CellPadding="3" AllowColumResize="True" onsorting="grdDetails_Sorting" GridLines="None" CssClass="mGrid" PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt">
<Columns>
答案 0 :(得分:1)
检查您是否使用了正确的标签ID。因为在您的示例中,标签ID不一致。在您的活动中更新正确的标签。
答案 1 :(得分:0)
我将UpdateMode =“ Conditional”更改为UpdateMode =“ Always”多亏了我在how to update a control in another updatepanel?
中找到的答案