This is a discussion on Create control according to their data type within the .Net Development forums, part of the Programming & Scripting category; I would use a direct SQL data reader... Only thing to remember with a repeater is the control itself doesn't ...
| |||||||
|
#11
| ||||
| ||||
| I would use a direct SQL data reader... Only thing to remember with a repeater is the control itself doesn't render anything. So, unlike a gridview (I think) it won't put a <table> tag or <tr><td> tags for each row. All it does is render the details inside the various templates (Item, Alternating etc.) for each record in the datasource. Hope that helps.
__________________ Join the folding team |
| The Following User Says Thank You to richyrich For This Useful Post: | ||
guddu (January 19th, 2009) | ||
|
#12
| ||||
| ||||
| last doubt how to use repeater control with business and data layer. any sample code u refer?
__________________ Love is physical attraction and mental destruction |
|
#13
| ||||
| ||||
| You just set the datasource of the repeater to the function that returns the data from the database. Code: sub Page_Load()
If Not IsPostback then
repeater1.Datasource = BLL.GetData()
repeater1.Databind()
End If
End Sub
Code: <asp:repeater id="repeater1" runat="server" OnItemDataBind="repeater1_OnItemDataBind"> . . </asp:repeater> Code: Sub repeater1_OnItemDataBind(ByVal s As Object, ByVal e As RepeaterItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItem.AlternatingItem then
Dim objBOL As BOLObject = e.Item.DataItem
If objBOL.your_property = "whatever" then
'do this
End if
End If
End Sub
|
|
#14
| ||||
| ||||
| hi i want to give unique id to my text box .i m getting server tag not well formed tag? Code: <asp:TableCell runat="server" Width="10%">
<asp:TextBox runat="server" ID="txtBox<%# DataBinder.Eval(Container.DataItem, "DataTypeN0")%>"></asp:TextBox>
<asp:ListBox runat="server" ID="lstBox<%# DataBinder.Eval(Container.DataItem, "DataTypeN0")%>"></asp:ListBox>
</asp:TableCell>
|
|
#15
| ||||
| ||||
| Try changing the " to ' Code: <asp:TableCell runat="server" Width="10%">
<asp:TextBox runat="server" ID='txtBox<%# DataBinder.Eval(Container.DataItem, "DataTypeN0")%>'></asp:TextBox>
<asp:ListBox runat="server" ID='lstBox<%# DataBinder.Eval(Container.DataItem, "DataTypeN0")%>'></asp:ListBox>
</asp:TableCell>
|
|
#16
| ||||
| ||||
| now getting below error Error1 'txtBox<%# DataBinder.Eval(Container.DataItem, "DataTypeN0")%>' is not a valid identifier. |
|
#17
| ||||
| ||||
| hi and with above i m looking for this also. Code: <ItemTemplate>
<asp:Table runat="server" Width="60%" HorizontalAlign="Center">
<asp:TableRow runat="server">
<asp:TableCell runat="server" Width="10%">
<%# DataBinder.Eval(Container.DataItem, "Description")%>
</asp:TableCell>
<asp:TableCell runat="server" Width="10%">
<%# DataBinder.Eval(Container.DataItem, "DataType")%>
+
<%# DataBinder.Eval(Container.DataItem, "DataTypeN0")%>
</asp:TableCell>
<asp:TableCell runat="server" Width="10%">
<asp:TextBox runat="server" ID='txtBox<%# DataBinder.Eval(Container.DataItem, "DataTypeN0")%>'></asp:TextBox>
<asp:ListBox runat="server" ID='lstBox<%# DataBinder.Eval(Container.DataItem, "DataTypeN0")%>'></asp:ListBox>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</ItemTemplate>
|
|
#18
| ||||
| ||||
| .NET assigns unique IDs to controls automatically. Is there any reason you want to change them to something else? If you want to make changes to the IDs of controls etc. and also for checking values of items and changing the details displayed accordingly, use the OnItemDataBound method of your repeating control. Then, for each item it binds, you can retrieve the controls and values and make any alterations before the code is rendered. Hope that helps. |
|
#19
| ||||
| ||||
| hi Thanks for a reply.i skipped the idea of assigning id.and for display purpose i m doing like this and i think i m fine with this Code: <asp:TextBox runat="server" Visible='<%#VisibleTextBoxYesNo(DataBinder.Eval(Container .DataItem,
"DataTypeN0").ToString())%>' ID='txtBox'></asp:TextBox>
protected bool VisibleTextBoxYesNo(string val)
{
if (val == "1" || val == "2" || val == "3")
return (true);
return (false);
}
|
|
#20
| ||||
| ||||
| now i m facing problem with paging in repeater.i m using datasource to make paging work but i m getting below error at bind line. Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index Code: PackageList dd = PackageListBL.GetExtraInfo(121);
if (dd != null)
{
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = dd;
objPds.AllowPaging = true;
objPds.PageSize = 5;
objPds.CurrentPageIndex = CurrentPage - 1;
rptExtraInfo.DataSource = objPds;
rptExtraInfo.DataBind();
}
|
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Create/Print Form data | Rebelle | ASP Development | 5 | December 10th, 2008 10:25 AM |
| Binding data to the RadioButtonList Control | Shem | .Net Development | 2 | December 3rd, 2008 02:42 AM |
| The data source 'ObjectDataSource1' does not support sorting with IEnumerable data | Shem | .Net Development | 5 | June 25th, 2008 08:07 AM |
| Data Type Mismatch in Criteria Expression | alansidman | Microsoft Access | 1 | April 9th, 2008 04:33 PM |
| [Error] Type mismatch: HTMLEncode | Rebelle | ASP Development | 20 | March 28th, 2008 09:30 AM |