Problem with a nested repeater
-
Hi, I'm trying to work with nested repeaters. I have repeater 1(called repDetails), where I list errors (from table 1). To each error (row from table 1) there is a file list (from table 2). Each row with error has a unique errorCyklusId witch also is used in table 2 (so I can see which files belongs to which error) I want my nested repeater (called repFiles) to show alle file names (from table 2). I need to figure out, how I in ItemDataBound can find the first repeters errorcyklusId for each row and how I can call a control (in this case a hyperlink control) from ItemDataBound My code:
ID:
1 protected void repDetails_ItemDataBound(object sender, RepeaterItemEventArgs e) 2 { 3 //int errorCyklusId = Convert.ToInt32(e.CommandArgument); 4 5 if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) 6 { 7 try 8 { 9 ERSError error = new ERSError(); 10 11 DataTable filelist = null; 12 13 if (error.GetFileList(1, ref filelist) == Status.Success) 14 { 15 int companyid = Convert.ToInt32(Session[ERSConnect.CookieCompanyId]); 16 17 RepeaterItem item = e.Item; 18 Repeater repFiles = item.FindControl("repFiles") as Repeater; 19 repFiles.DataSource = filelist.DefaultView; 20 repFiles.DataBind(); 21 } 22 } 23
-
Hi, I'm trying to work with nested repeaters. I have repeater 1(called repDetails), where I list errors (from table 1). To each error (row from table 1) there is a file list (from table 2). Each row with error has a unique errorCyklusId witch also is used in table 2 (so I can see which files belongs to which error) I want my nested repeater (called repFiles) to show alle file names (from table 2). I need to figure out, how I in ItemDataBound can find the first repeters errorcyklusId for each row and how I can call a control (in this case a hyperlink control) from ItemDataBound My code:
ID:
1 protected void repDetails_ItemDataBound(object sender, RepeaterItemEventArgs e) 2 { 3 //int errorCyklusId = Convert.ToInt32(e.CommandArgument); 4 5 if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) 6 { 7 try 8 { 9 ERSError error = new ERSError(); 10 11 DataTable filelist = null; 12 13 if (error.GetFileList(1, ref filelist) == Status.Success) 14 { 15 int companyid = Convert.ToInt32(Session[ERSConnect.CookieCompanyId]); 16 17 RepeaterItem item = e.Item; 18 Repeater repFiles = item.FindControl("repFiles") as Repeater; 19 repFiles.DataSource = filelist.DefaultView; 20 repFiles.DataBind(); 21 } 22 } 23
-
Use
tags to format your code. It's pretty much impossible to read your message.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush -
Hi, Thanks, I was not awear about I should that too...... I thought that code was that I should use........ Shall I know post my question again or how? Kind regards, simsen :-)
<pre/> tags are better for code listings. For instance:
<asp:Repeater ID="repDetails" runat="server" OnItemDataBound="repDetails_ItemDataBound">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
ID: <asp:Label ID="lblDetailsFiles" runat="server" Text='<%# Eval("errorCyklusId") %>'></asp:Label>
<asp:Repeater ID="repFiles" runat="server">
<ItemTemplate> <asp:HyperLink ID="lnkFile" runat="server" Text='<%# Eval("fileName") %>' Target="_blank" NavigateUrl=""></asp:HyperLink>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush
-
Hi, Thanks, I was not awear about I should that too...... I thought that code was that I should use........ Shall I know post my question again or how? Kind regards, simsen :-)
Yes I understood you. I hope you can help me with my problem instead....... I cann't figure out, how I get the rows "signature", so I can call the database again for selecting to the nested repeater. And how I can change the NavigateURL for each row in the nested repeater? My code:
ID: \]\]>'> \]\]>' Target="\_blank" NavigateUrl="">
1 protected void repDetails_ItemDataBound(object sender, RepeaterItemEventArgs e)
2 {
3 //int errorCyklusId = Convert.ToInt32(e.CommandArgument);
4
5 if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
6 {
7 try
8 {
9 ERSError error = new ERSError();
10
11 DataTable filelist = null;
12
13 if (error.GetFileList(1, ref filelist) == Status.Success)
14 {
15 int companyid = Convert.ToInt32(Session[ERSConnect.CookieCompanyId]);
16
17 RepeaterItem item = e.Item;
18 Repeater repFiles = item.FindControl("repFiles") as Repeater;
19 repFiles.DataSource = filelist.DefaultView;
20 repFiles.DataBind();
21 }
22 }
23 catch
24 { }
25 }
26 }Kind regards, simsen :-) Kind regards, simsen :-)