VB.NET直放站简单数据绑定的数据源不 [英] VB.NET Repeater Simple Data Binding Without Datasource
问题描述
我有一个必须在网页上的中继器的一种形式。我有告诉我更多的客户信息有多少是添加了一些参数。在这个页面我有一个需要重复的项目设定次数Repeater控件。每个项目的存在需要附加到它的ID的一组输入框。我只需要绑定是即&LT每增加一个输入框中输入一个数字;%#ID%GT;
。我不知道如何设置简单的数据绑定没有一个具体的数据源,但只建立一条一个循环。
< ASP:直放站ID =myRepeater=服务器>
<&HeaderTemplate中GT;
< DIV CLASS =AdditionalRowTitle>
< DIV CLASS =AdditionalCellTitle>标题< / DIV>
< DIV CLASS =AdditionalCellFirstName>首先名称和LT; / DIV>
< DIV CLASS =AdditionalCellLastName>姓< / DIV>
< DIV CLASS =AdditionalCellDOB> DOB< / DIV>
< DIV CLASS =AdditionalCellRelationship>往来及LT; / DIV>
< / DIV>
< / HeaderTemplate中> <&ItemTemplate中GT;
< DIV CLASS =AdditionalRow>
< DIV CLASS =AdditionalInputTitle>
< ASP:DropDownList的ID =AdTitle=服务器>
< ASP:列表项选择=真值=文本=/>
< ASP:列表项选择=FALSE值=小姐文本=小姐/>
< ASP:列表项选择=FALSE值=小姐文本=小姐/>
< ASP:列表项选择=FALSE值=太太文本=太太/>
< ASP:列表项选择=FALSE值=先生文本=先生/>
< ASP:列表项选择=FALSE值=其他文本=其他/>
< / ASP:DropDownList的>
< / DIV> < DIV CLASS =AdditionalInputFirstName>
< ASP:文本框ID =AdFirstName=服务器>< / ASP:文本框>
< / DIV> < DIV CLASS =AdditionalInputLastName>
< ASP:文本框ID =AdLastName=服务器>< / ASP:文本框>
< / DIV> < DIV CLASS =AdditionalInputDOB>
< ASP:DropDownList的ID =AdDOBDay=服务器>
< ASP:列表项选择=真值=文本=/>
&所述; asp的:列表项选定=假值=1的文本=1/>
< ASP:列表项选择=FALSE值=2文本=2/>
< ASP:列表项选择=FALSE值=3文本=3/>
< ASP:列表项选择=FALSE值=4文本=4/>
< ASP:列表项选择=FALSE值=5文本=10/>
< ASP:列表项选择=FALSE值=6文本=6/>
< ASP:列表项选择=FALSE值=7文本=7/>
< ASP:列表项选择=FALSE值=8文本=8/>
< ASP:列表项选择=FALSE值=9文本=9/>
< ASP:列表项选择=FALSE值=10文本=10/>
< ASP:列表项选择=FALSE值=11文本=11/>
< ASP:列表项选择=FALSE值=12文本=12/>
< ASP:列表项选择=FALSE值=13文本=13/>
< ASP:列表项选择=FALSE值=14文本=14/>
< ASP:列表项选择=FALSE值=15文本=15/>
< ASP:列表项选择=FALSE值=16文本=16/>
< ASP:列表项选择=FALSE值=17文本=17/>
< ASP:列表项选择=FALSE值=18文本=18/>
< ASP:列表项选择=FALSE值=19文本=19/>
< ASP:列表项选择=FALSE值=20文本=20/>
< ASP:列表项选择=FALSE值=21文本=21/>
< ASP:列表项选择=FALSE值=22文本=22/>
< ASP:列表项选择=FALSE值=23文本=23/>
< ASP:列表项选择=FALSE值=24文本=24/>
< ASP:列表项选择=FALSE值=25文本=25/>
< ASP:列表项选择=FALSE值=26文本=26/>
< ASP:列表项选择=FALSE值=27文本=27/>
< ASP:列表项选择=FALSE值=28文本=28/>
< ASP:列表项选择=FALSE值=29文本=29/>
< ASP:列表项选择=FALSE值=30文本=30/>
< ASP:列表项选择=FALSE值=31文本=31/>
< / ASP:DropDownList的> < ASP:DropDownList的ID =AdDOBMonth=服务器>
< ASP:列表项选择=真值=文本=/>
< ASP:列表项选择=FALSE值=1文本=一月/>
< ASP:列表项选择=FALSE值=2文本=Febuary/>
< ASP:列表项选择=FALSE值=3文本=三八/>
< ASP:列表项选择=FALSE值=4文本=四五/>
< ASP:列表项选择=FALSE值=5文本=五一/>
< ASP:列表项选择=FALSE值=6文本=六一/>
< ASP:列表项选择=FALSE值=7文本=七一/>
< ASP:列表项选择=FALSE值=8文本=八一/>
< ASP:列表项选择=FALSE值=9文本=九月/>
< ASP:列表项选择=FALSE值=10文本=十一/>
< ASP:列表项选择=FALSE值=11文本=11月。/>
< ASP:列表项选择=FALSE值=12文本=十二月/>
< / ASP:DropDownList的> < ASP:DropDownList的ID =AdDOBYear=服务器>
< / ASP:DropDownList的> &所述; ajaxToolkit:CascadingDropDown ID =CascadingDropDown2
类别=AdDOBYear
LoadingText =
ServicePath =TravelWebService.asmx
ServiceMethod =GetYears
PromptText =
的TargetControlID =AdDOBYear
=服务器>
< / ajaxToolkit:CascadingDropDown>
< / DIV> < DIV CLASS =AdditionalInputRelationship>
< ASP:DropDownList的ID =AdRelationship=服务器>
< ASP:列表项选择=真值=文本=/>
< ASP:列表项选择=FALSE值=合作伙伴文本=合作伙伴/>
< ASP:列表项选择=FALSE值=孩子文本=孩子/>
< ASP:列表项选择=FALSE值=不相关文本=不相关/>
< / ASP:DropDownList的>
< / DIV>
< / DIV>
< / ItemTemplate中>
< / ASP:直放站>
下面是重复项的方法。在您的网页加载事件,添加以下内容:
暗淡repeatTimes()作为整数=新的整数(){1,2,3}
myRepeater.DataSource = repeatTimes
myRepeater.DataBind()
的转发器的物品将通过在阵列元素的数量被重复。在这种情况下,有3个要素。阵列的实际内容并不重要,元件的刚数目
编辑:我不知道VB.NET那么好,但我认为这应该工作
小组的Page_Load()
昏暗NumberToRepeat作为整数''*应该来自参数
如果没有Page.IsPostBack然后
昏暗的repeatTimes(NumberToRepeat)作为整数
myRepeater.DataSource = repeatTimes
myRepeater.DataBind()
万一
结束小组
I've got a form that has to be a repeater on a webpage. I have a number parameter that tells me how many additional customer details are to be added. In this page I have a repeater control that needs to repeat items a set number of times. For each item there is a set of input boxes that needs an id appended to it. All I need to bind is a number for each additional input box ie <% #id %>
. I dont know how to set up simple databind without a specific datasource, but just build one in a loop.
<asp:Repeater ID="myRepeater" runat="server">
<HeaderTemplate>
<div class="AdditionalRowTitle">
<div class="AdditionalCellTitle">Title</div>
<div class="AdditionalCellFirstName">First Name</div>
<div class="AdditionalCellLastName">Last Name</div>
<div class="AdditionalCellDOB">DOB</div>
<div class="AdditionalCellRelationship">Relationship</div>
</div>
</HeaderTemplate>
<ItemTemplate>
<div class="AdditionalRow">
<div class="AdditionalInputTitle">
<asp:DropDownList ID="AdTitle" runat="server">
<asp:ListItem Selected="True" Value="" Text=""/>
<asp:ListItem Selected="False" Value="Miss" Text="Miss"/>
<asp:ListItem Selected="False" Value="Ms" Text="Ms"/>
<asp:ListItem Selected="False" Value="Mrs" Text="Mrs"/>
<asp:ListItem Selected="False" Value="Mr" Text="Mr"/>
<asp:ListItem Selected="False" Value="Other" Text="Other"/>
</asp:DropDownList>
</div>
<div class="AdditionalInputFirstName">
<asp:TextBox ID="AdFirstName" runat="server"></asp:TextBox>
</div>
<div class="AdditionalInputLastName">
<asp:TextBox ID="AdLastName" runat="server"></asp:TextBox>
</div>
<div class="AdditionalInputDOB">
<asp:DropDownList ID="AdDOBDay" runat="server">
<asp:ListItem Selected="True" Value="" Text=""/>
<asp:ListItem Selected="False" Value="1" Text="1"/>
<asp:ListItem Selected="False" Value="2" Text="2"/>
<asp:ListItem Selected="False" Value="3" Text="3"/>
<asp:ListItem Selected="False" Value="4" Text="4"/>
<asp:ListItem Selected="False" Value="5" Text="5"/>
<asp:ListItem Selected="False" Value="6" Text="6"/>
<asp:ListItem Selected="False" Value="7" Text="7"/>
<asp:ListItem Selected="False" Value="8" Text="8"/>
<asp:ListItem Selected="False" Value="9" Text="9"/>
<asp:ListItem Selected="False" Value="10" Text="10"/>
<asp:ListItem Selected="False" Value="11" Text="11"/>
<asp:ListItem Selected="False" Value="12" Text="12"/>
<asp:ListItem Selected="False" Value="13" Text="13"/>
<asp:ListItem Selected="False" Value="14" Text="14"/>
<asp:ListItem Selected="False" Value="15" Text="15"/>
<asp:ListItem Selected="False" Value="16" Text="16"/>
<asp:ListItem Selected="False" Value="17" Text="17"/>
<asp:ListItem Selected="False" Value="18" Text="18"/>
<asp:ListItem Selected="False" Value="19" Text="19"/>
<asp:ListItem Selected="False" Value="20" Text="20"/>
<asp:ListItem Selected="False" Value="21" Text="21"/>
<asp:ListItem Selected="False" Value="22" Text="22"/>
<asp:ListItem Selected="False" Value="23" Text="23"/>
<asp:ListItem Selected="False" Value="24" Text="24"/>
<asp:ListItem Selected="False" Value="25" Text="25"/>
<asp:ListItem Selected="False" Value="26" Text="26"/>
<asp:ListItem Selected="False" Value="27" Text="27"/>
<asp:ListItem Selected="False" Value="28" Text="28"/>
<asp:ListItem Selected="False" Value="29" Text="29"/>
<asp:ListItem Selected="False" Value="30" Text="30"/>
<asp:ListItem Selected="False" Value="31" Text="31"/>
</asp:DropDownList>
<asp:DropDownList ID="AdDOBMonth" runat="server">
<asp:ListItem Selected="True" Value="" Text=""/>
<asp:ListItem Selected="False" Value="1" Text="January"/>
<asp:ListItem Selected="False" Value="2" Text="Febuary"/>
<asp:ListItem Selected="False" Value="3" Text="March"/>
<asp:ListItem Selected="False" Value="4" Text="April"/>
<asp:ListItem Selected="False" Value="5" Text="May"/>
<asp:ListItem Selected="False" Value="6" Text="June"/>
<asp:ListItem Selected="False" Value="7" Text="July"/>
<asp:ListItem Selected="False" Value="8" Text="August"/>
<asp:ListItem Selected="False" Value="9" Text="September"/>
<asp:ListItem Selected="False" Value="10" Text="October"/>
<asp:ListItem Selected="False" Value="11" Text="November"/>
<asp:ListItem Selected="False" Value="12" Text="December"/>
</asp:DropDownList>
<asp:DropDownList ID="AdDOBYear" runat="server">
</asp:DropDownList>
<ajaxToolkit:CascadingDropDown ID="CascadingDropDown2"
Category="AdDOBYear"
LoadingText=""
ServicePath="TravelWebService.asmx"
ServiceMethod="GetYears"
PromptText=""
TargetControlID="AdDOBYear"
runat="server">
</ajaxToolkit:CascadingDropDown>
</div>
<div class="AdditionalInputRelationship">
<asp:DropDownList ID="AdRelationship" runat="server">
<asp:ListItem Selected="True" Value="" Text=""/>
<asp:ListItem Selected="False" Value="Partner" Text="Partner"/>
<asp:ListItem Selected="False" Value="Child" Text="Child"/>
<asp:ListItem Selected="False" Value="Unrelated" Text="Unrelated"/>
</asp:DropDownList>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
Here's a way to repeat the items. In your page load event, add the following:
Dim repeatTimes() As Integer = New Integer(){1, 2, 3}
myRepeater.DataSource = repeatTimes
myRepeater.DataBind()
The repeater items will be repeated by the number of elements in the Array. In this case, there are 3 elements. The actual contents of the array don't matter, just the number of elements.
EDIT: I don't know VB.NET that well, but I think this should work
Sub Page_Load()
Dim NumberToRepeat As Integer ''*Should come from the parameter
If Not Page.IsPostBack Then
Dim repeatTimes(NumberToRepeat) As Integer
myRepeater.DataSource = repeatTimes
myRepeater.DataBind()
End If
End Sub
这篇关于VB.NET直放站简单数据绑定的数据源不的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!