每次某个SQL字段更改值时,创建一个新的ASP:repeater [英] Create a new ASP:repeater every time a certain SQL field changes value
问题描述
大家好,
希望你好。并且提前感谢您提供给我的任何帮助。
我有一个系统,需要创建一个基于a的转发器(带有一个新的标头)从sql查询返回的值
例如我的表中包含如下信息:
字段1 | Field 2 | field 3
info 1 info 1
info info 1
info info 2
info info 2
info info 2
任何想法如何在运行时根据数据库表格中的数据内容动态(可编程)创建转发器
在运行时为所有信息创建转发器或者有些很容易,但是如果字段3更改值2,则不知道如何创建另一个转发器 - 因此对于值为2的所有条目都是如此在转发器中,所有值为1的条目将它们创建为转发器
希望这是正确的。但是从明天起可能会有6个场地值为4,我希望它再次相同并将4个组合在一起..
所以换句话说创建每个具有相同价值的现场组的转发器3
前端代码如下所示:
Hi All,
hope you are well. and thank you in advance for any help you can give me on this.
I have a system, that requires a repeater created (with a new header) based on a value returned from the sql query
for example my table holds information like follows:
Field 1 | Field 2 | field 3
info 1 info 1
info info 1
info info 2
info info 2
info info 2
any idea how i would create a repeater dynamically (programmably) during runtime based on the contents of my data in database table
creating a repeater at runtime for all infomration or some is easy, but dont know how to create another one if field 3 changes value 2 - so for all entries with value 2 place in a repeater, all entries with value 1 create them into a repeater
hope this is coming across correctly. but since tomorrow there could be 6 entires with field value of 4, i want to it do the same again and group the 4's together..
so in other words create a repeater for every group of entiries with same value in field3
Front end code looks like follows:
<asp:Repeater ID="SKillsTOEnter" runat="server">
<HeaderTemplate>
<table width="50%">
<tr>
<th>Field1</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td width="80%"><Asp:label id="fieldinfo" Text=<%#DataBinder.Eval(Container.DataItem, "Field1")%> runat="server"></Asp:label></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
提前致谢
Robert Belsten
我尝试了什么:
i可以创建一个单独的asp转发器来拉取它们,但不能添加一个字段3更改值时的标题或字段3中值更改时创建新的转发器
后端代码
Thanks in advance
Robert Belsten
What I have tried:
i can create a single asp repeater to pull them all , but not one to add a header when field 3 changes value or create a new repeater when value changes in field 3
Backend code
myCommand = New SqlDataAdapter("select Field1, field2, FIeld3 From Table1 Order By FIELD2 ", myConnection)
myCommand.Fill(ds)
SKillsTOEnter.DataSource = ds
SKillsTOEnter.DataBind()
推荐答案
这样的事情怎么样:
How about something like this:
SkillsToEnter.DataSource = ds.Tables(0).GroupBy(Function (row) row.Field(Of Integer)("Field3"))
SkillsToEnter.DataBind()
<asp:Repeater id="SkillsToEnter" runat="server">
<ItemTemplate>
<h1>Field3: <%# Eval("Key") %></h1>
<asp:Repeater runat="server" DataSource='<%# Container.DataItem %>'>
<HeaderTemplate>
<table style="width:50%">
<thead>
<tr>
<th>Field1</th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td style="width:80%">
<asp:label id="fieldinfo" runat="server" Text='<%# Eval("Field1") %>' />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody>
</table>
</FooterTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
这篇关于每次某个SQL字段更改值时,创建一个新的ASP:repeater的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!