0

I am fairly new to ASP.NET and I am trying to add the number i created in the backend to be inserted into the label text field in the front-end but Im not being able to access the Label (lblAmountNumber) inside the Repeater i guess it is not allowing me to access the ID=lblAmountNumber and the name of my repeater is RpMember

I have my simple code down below

FRONT END

                            <asp:Repeater ID="RpMember" runat="server">
                                <HeaderTemplate>
                                    <table id="example1" class="table table-bordered table-hover">
                                        <thead>
                                            <tr>                                                                                      
                                                <th style="min-width: 100px">
                                                    <asp:Label ID="Label2" runat="server" Text="MemberInfo"></asp:Label></th>
                                                <th style="min-width: 100px">
                                                    <asp:Label ID="Label3" runat="server" Text="Amount Number"></asp:Label></th>
                                                <th style="min-width: 100px">
                                                    <asp:Label ID="Label5" runat="server" Text="Loan Balance"></asp:Label></th>
                                                <th style="min-width: 100px">
                                                    <asp:Label ID="Label1" runat="server" Text="Savings Balance"></asp:Label></th>
                                                <th style="min-width: 100px" class="ButtonView">
                                                    <asp:Label ID="Label6" runat="server"></asp:Label></th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <tr style="text-align: center">
                                        
                                        <td style="width: 100px; text-align: left; text-transform: capitalize"><%#Eval("Name") %>
                                            <br />
                                            <%#Eval("Phone") %>
                                             <br />
                                            <%#Eval("Address") %>
                                        </td>
                                        <td style="width: 100px"><asp:Label ID="lblAmountNumber" runat="server"></asp:Label></th></td>
                                        <td style="width: 100px"><%#Eval("LoanBalance") %></td>
                                        <td style="width: 100px"><%#Eval("SavingsBalance") %></td>
                                        <td style="text-align: center; width: 100px" class="ButtonView">                                            
                                            <asp:LinkButton ID="ReportLinkBtn" runat="server" OnClick="ReportLinkBtn_Click" CommandArgument='<%# Eval("MemberId")%>' CssClass="btn btn-success" Text="Report Details" />
                                        </td>
                                    </tr>
                                </ItemTemplate>
                                <FooterTemplate>
                                    </tbody>
                          </table>
                                </FooterTemplate>
                            </asp:Repeater>

BACKEND

DataTable dt2 = objdalTransactionEntry.GetLoanTakerStartAmountByLoanTakerId(Sessions.Name.UserId, MemberId);
            foreach (RepeaterItem item in RpMember.Items)
            {
                Label lab = item.FindControl("lblHishabNumber") as Label;
                string yearForHishabNumber = Convert.ToDateTime(dt2.Rows[0]["EntryDate"].ToString()).Year.ToString();
                string monthForHishabNumber = Convert.ToDateTime(dt2.Rows[0]["EntryDate"].ToString()).ToString("MM");
                string yearForInvoiceNumber = Convert.ToDateTime(dt2.Rows[0]["EntryDate"].ToString()).Year.ToString();
                string monthForInvoiceNumber = Convert.ToDateTime(dt2.Rows[0]["EntryDate"].ToString()).ToString("MM");
                string dayForInvoiceNumber = Convert.ToDateTime(dt2.Rows[0]["EntryDate"].ToString()).ToString("dd");
                lab.Text = "Amount Number " + monthForHishabNumber + yearForHishabNumber.Substring(yearForHishabNumber.Length - 2) + dt2.Rows[0]["UserWiseID"].ToString();
                
            }
M_O_MEN
  • 1
  • 2
  • Are you getting any error? What's the exact issue? – Chetan Jan 06 '21 at 11:25
  • I am not being able to access the label ID i am trying to load some data but its not appearing – M_O_MEN Jan 06 '21 at 11:28
  • The code you shared , when does it execute? Did you debug the code? Are you loading data in repeater? How do you load the data? Can you share bit more code ? – Chetan Jan 06 '21 at 11:35

0 Answers0