我有updatePanel,其中我正在显示表格
<asp:UpdatePanel ID="DynCreated" EnableViewState="true" UpdateMode="Conditional"
runat="server">
<ContentTemplate >
<div style="display: none" enableviewstate="true">
<asp:TextBox ID="flgClear" EnableViewState="true" Text="" runat="server"></asp:TextBox>
<asp:TextBox ID="flgAdd" EnableViewState="true" Text="" runat="server"></asp:TextBox>
<asp:TextBox ID="txtList" EnableViewState="true" Text="|" runat="server"></asp:TextBox>
<asp:TextBox ID="txtDelete" EnableViewState="true" Text="|" runat="server"></asp:TextBox></div>
<asp:Table ID="tblGrid" CssClass="grid" CellPadding="0" CellSpacing="0"
Width="100%" EnableViewState="true" runat="server"> <asp:TableRow TableSection="TableHeader" ID="trHeader" CssClass="crid-header Datagrid-header"
runat="server" EnableViewState="true">
<asp:TableHeaderCell ID="hdrSequence" runat="server">
<asp:Label ID="lblSequence" Text="#" CssClass="cel" runat="server" />
</asp:TableHeaderCell>
<asp:TableHeaderCell ID="hdrHouseBill" runat="server">
<asp:Label ID="lblHouseBill" Text="HouseBill" CssClass="ceva-form-label" runat="server" />
</asp:TableHeaderCell>
<asp:TableHeaderCell ID="hdrFileNumber" runat="server">
<asp:Label ID="lblFileNumber" Text="FileNumbere" CssClass="ceva-form-label" runat="server" />
</asp:TableHeaderCell>
</asp:TableRow>
</asp:Table>
<br />
<br />
<div class="text-center">
<asp:Button ID="btnAddNewHB" CssClass="tn btn-dialog" Text="Add New Status"
OnClientClick="return ShowNewLeg();" runat="server" />
<asp:Button Text="Validate" CssClass="cen btn-dialog" runat="server" ID="btnValidate" />
<asp:Button ID="btnSave" CssClass="tn-dialog" Text="Save" OnClientClick="return Save()" Visible="false"
runat="server" />
<asp:Button ID="btnCancel" CssClass=" btn-dialog" OnClientClick="window.returnValue = 1; window.close(); return false;"
Text="Cancel" CausesValidation="false" runat="server" />
<asp:Button ID="btnClear" CssClass=tn btn-dialog" Text="Clear All" OnClientClick="return ClearTable();"
runat="server" />
<input type="hidden" id="hndtimeformat" runat="server" name="hndtimeformat" value="0"
style="display: none" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
从后端我将新行添加到tblGrid
For j As Integer = tblGrid.Rows.Count To maxRow
Dim newRow As TableRow= New TableRow()
newRow.Cells.Add(CreateNewLabel(tblGrid.Rows.Count, "SEQ",
tblGrid.Rows.Count, tblGrid.Rows.Count, "40px", bColor))
newRow.Cells.Add(CreateNewText(tblGrid.Rows.Count, "HB", "",
tblGrid.Rows.Count, "10px", "", 3, "none", False))
newRow.Cells.Add(CreateNewLabel(tblGrid.Rows.Count, "FN", "", tblGrid.Rows.Count, "60px", ""))
newRow.Cells.Add(CreateNewDD(tblGrid.Rows.Count, "ST", statusup, tblGrid.Rows.Count, "10px", "", 3, "none", True))
newRow.Cells.Add(CreateNewDT(tblGrid.Rows.Count, "datetime", "", tblGrid.Rows.Count, ""))
newRow.Cells.Add(CreateNewAC(tblGrid.Rows.Count, "LC", "", "", tblGrid.Rows.Count, "0.0", AutoCompletor.DisplayFieldType.Code, "", "", False))
newRow.Cells.Add(CreateNewText(tblGrid.Rows.Count, "SG", "", tblGrid.Rows.Count, "10px", "", 0, "none"))
newRow.Cells.Add(CreateNewCB(tblGrid.Rows.Count, "CB", "", tblGrid.Rows.Count, "5px", bColor))
newRow.Cells.Add(CreateNewText(tblGrid.Rows.Count, "Note", "", tblGrid.Rows.Count, "10px", "", 0, "none"))
newRow.Cells.Add(CreateNewLabel(tblGrid.Rows.Count, "Er", "", tblGrid.Rows.Count, "40px", bColor))
newRow.Cells.Add(CreateNewImage(tblGrid.Rows.Count, "btn", tblGrid.Rows.Count)) tblGrid.Rows.Add(newRow) Next j
我在回发之前得到的数据是我在回复之前得到的数据,之后回复它没有tabGrid中存在的任何数据。
我是否需要使用ViewState或Session?有什么方法可以获得数据吗? 请指教!!
答案 0 :(得分:0)
将您的数据放入视图状态并在回发后获取它们
答案 1 :(得分:0)
如果您只需要在此页面内导航期间使用此数据,则可以使用ViewState变量。如果你想让整个会话的保持活动数据更好地使用Session变量,那么如果你进入其他页面,你也不会丢失这些行。
Asp:如果你想管理数据,Table不是正确的元素,我建议试试这个解决方案(只是一个例子):
# Get all <li> inside <ul>[1]
CarBrands = tree.xpath('//*[@id="content"]/ul[1]/li')
# Iterate all <li> Nodes
for node in CarBrands:
# Findall <ul><li>...</li> ...
li_nodes = node.findall('./ul/li')
# Iterate all <li>
for li in li_nodes:
# Find the <a> inside <li>
a = li.find('./a')
# Clear "special text nodes"
a.tail = ''
print('a:{}'.format(etree.tostring(a)))
这对于运行时数据绑定: 创建数据表
a:b'<a href="/Biler/AC/Ace/">Ace</a>'
a:b'<a href="/Biler/AC/Cobra/">Cobra</a>'
在回发中绑定:
<asp:GridView runat="server" ID="tblGrid" CssClass="grid" CellPadding="0" CellSpacing="0">
<Columns >
<asp:TemplateField >
<HeaderTemplate >
<asp:Label ID="lblSequence" Text="#" CssClass="cel" runat="server" />
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblSequenceItem" Text="<%# Eval("col1") %>" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
<asp:Label ID="lblHouseBill" Text="HouseBill" CssClass="ceva-form-label" runat="server" />
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblHouseBillItem" Text="<%# Eval("col2") %>" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
<asp:Label ID="lblFileNumber" Text="FileNumbere" CssClass="ceva-form-label" runat="server" />
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblFileNumberItem" Text="<%# Eval("col3") %>" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>