Link to home
Start Free TrialLog in
Avatar of omegalove
omegalove

asked on

Need to fix the following from gridview to repeater.

I need to have the following to work as a repeater
I appreciate any help.
private void SetData()
        {
            int currentCount = 0;
            CheckBox chkAll = (CheckBox)Inbox.HeaderRow.Cells[0].FindControl("chkAll");
            chkAll.Checked = true;
            ArrayList arr = (ArrayList)ViewState["SelectedRecords"];
            for (int i = 0; i < Inbox.Rows.Count; i++)
            {
                CheckBox chk = (CheckBox)Inbox.Rows[i].Cells[0].FindControl("chk");
                if (chk != null)
                {
                    chk.Checked = arr.Contains(Inbox.DataKeys[i].Value);
                    if (!chk.Checked)
                        chkAll.Checked = false;
                    else
                        currentCount++;
                }
            }
            hfCount.Value = (arr.Count - currentCount).ToString();
        }

Open in new window

Avatar of HainKurt
HainKurt
Flag of Canada image

whats the issue with this code? what is not working and what error do you get (if any)
Avatar of omegalove
omegalove

ASKER

Can you then help me put the following in a gridview form.
<table cellpadding="0" cellspacing="0" class="mbx" style="margin-top: 0;">
    <tr>
        <th class="status" style="text-align: center">
            ?
        </th>
        <th class="cbox" style="text-align: center">
            <asp:CheckBox ID="chkAll" runat="server" onclick="checkAll(this);" />
        </th>
        <th class="sender">
            <asp:Label ID="lblFrom" runat="server" Text="Label"></asp:Label>
        </th>
        <th class="title">
            <asp:Label ID="lblSubject" runat="server" Text="Label"></asp:Label>
        </th>
        <th class="date">
            <asp:Label ID="lblDate" runat="server" Text="Label"></asp:Label>
        </th>
        <th class="read">
            <asp:Label ID="lblRead" runat="server" Text="Label"></asp:Label>
        </th>
    </tr>
    <asp:Repeater ID="Inbox" runat="server">
        <FooterTemplate>
            <tr class="footer1">
                <td colspan="6" align="right">
                    <asp:Button ID="btnDelete" runat="server" Text="Delete Checked Records" OnClientClick="return ConfirmDelete();"
                        OnClick="btnDelete_Click" />
                </td>
            </tr>
            </table>
        </FooterTemplate>
        <ItemTemplate>
            <tr class="post">
                <td align="center">
                    <%--<img src='<%# GetImage(Container.DataItem) %>' />--%>
                </td>
                <td>
                    <asp:CheckBox ID="chk" runat="server" onclick="Check_Click(this)" />
                    <%--<a href='<%# yaf.Forum.GetLink(yaf.Pages.cp_message,"pm={0}",DataBinder.Eval(Container.DataItem,"UserPMessageID")) %>'>
                        <%# HtmlEncode(DataBinder.Eval(Container.DataItem,"Subject")) %></a>--%>
                    <%-- <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%#"~/Secure/ShowMessage.aspx?FromProfileID="+Eval("FromProfileID")+"&UserPMessageID="+Eval("UserPMessageID") + "&FromUsername=" + Eval("FromUsername") %>'>
                          <%# Convert.ToBoolean(DataBinder.Eval(Container, "DataItem.MsgRead")) ? "" : "<img src=\"../../Images/Icons/mail.gif\" align=\"bottom\" hspace=\"5\" border=\"0\">"%>
                          <%# DataBinder.Eval(Container.DataItem, "Subject") %></asp:HyperLink>--%>
                </td>
                <td>
                    <%# DataBinder.Eval(Container.DataItem,IsSentItems ? "ToUser" : "FromUser") %>
                </td>
                <td>
                    <%# DataBinder.Eval(Container.DataItem, "Subject") %>
                </td>
                <td>
                    <%# String.Format("{0:MMM-dd-yyyy HH:mm:ss tt}", ((System.Data.DataRowView)Container.DataItem)["Created"])%>
                    <%--<asp:HyperLink ID="HyperLink3" runat="server" NavigateUrl='<%#"~/Secure/ShowMessage.aspx?FromProfileID="+Eval("FromProfileID")+"&MessageID="+Eval("MessageId")  + "&FromUsername=" + Eval("FromUsername")  %>'>--%>
                    <%-- </asp:HyperLink>--%>
                </td>
                <td>
                    <%#DisplayDiscontinuedAsYESorNO(Convert.ToBoolean(Eval("IsRead")))%>
                    <asp:Label runat="server" ID="UserPMessageID" Visible="false" Text='<%# DataBinder.Eval(Container.DataItem,"UserPMessageID") %>' />
                </td>
            </tr>
        </ItemTemplate>
    </asp:Repeater>
    <asp:HiddenField ID="hfCount" runat="server" Value="0" />
    <br />
    (* Note: Message(s) will be automatically deleted after 30 days from the received
    date)
    <br />

Open in new window

how can I fix the following with the table?
<table cellpadding="0" cellspacing="0" class="mbx" style="margin-top: 0;">
    <tr>
        <th class="status" style="text-align: center">
            ?
        </th>
        <th class="cbox" style="text-align: center">
            <asp:CheckBox ID="chkAll" runat="server" onclick="checkAll(this);" />
        </th>
        <th class="sender">
            <asp:Label ID="lblFrom" runat="server" Text="Label"></asp:Label>
        </th>
        <th class="title">
            <asp:Label ID="lblSubject" runat="server" Text="Label"></asp:Label>
        </th>
        <th class="date">
            <asp:Label ID="lblDate" runat="server" Text="Label"></asp:Label>
        </th>
        <th class="read">
            <asp:Label ID="lblRead" runat="server" Text="Label"></asp:Label>
        </th>
    </tr>
    <asp:GridView ID="Inbox" runat="server" DataKeyNames="messageid" GridLines="None"
        OnPageIndexChanging="OnPaging" OnRowDataBound="Inbox_RowDataBound" Height="20px"
        HorizontalAlign="Center" VerticalAlign="Middle" AllowPaging="true" AllowSorting="true"
        EmptyDataText="No data available." PageSize="5" AutoGenerateColumns="false" CssClass="customers-grid">
        <AlternatingRowStyle Height="25px" HorizontalAlign="Center" BackColor="#D5E5FC" VerticalAlign="Middle" />
        <Columns>
            <asp:TemplateField HeaderText="Delete">
                <HeaderStyle CssClass="delete-member"></HeaderStyle>
                <ItemStyle CssClass="delete-member" Wrap="False"></ItemStyle>
                <HeaderTemplate>
                    <asp:CheckBox ID="chkAll" runat="server" onclick="checkAll(this);" />
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:CheckBox ID="chk" runat="server" onclick="Check_Click(this)" />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <HeaderStyle CssClass="from-pic"></HeaderStyle>
                <ItemStyle CssClass="from-pic" Wrap="False"></ItemStyle>
                <ItemTemplate>
                    <br />
                    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#"~/Secure/ShowMessage.aspx?FromProfileID="+Eval("FromProfileID")+"&MessageID="+Eval("MessageId")  + "&FromUsername=" + Eval("FromUsername")  %>'>
                        <asp:Image ID="MainPicID" BorderWidth="2" BorderColor="Silver" Style="vertical-align: middle"
                            class="srpic" runat="server" />
                    </asp:HyperLink><br />
                    <%#DataBinder.Eval(Container, "DataItem.FromUsername")%>
                    <asp:HiddenField ID="hiddenImgID" runat="server" Value='<%#DataBinder.Eval(Container,"DataItem.FromProfileID") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Subject" HeaderStyle-CssClass="subject" ItemStyle-CssClass="subject">
                <HeaderStyle CssClass="subject" />
                <ItemStyle CssClass="subject" />
                <ItemTemplate>
                    <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%#"~/Secure/ShowMessage.aspx?FromProfileID="+Eval("FromProfileID")+"&MessageID="+Eval("MessageId") + "&FromUsername=" + Eval("FromUsername") %>'>
		 <%# Convert.ToBoolean(DataBinder.Eval(Container, "DataItem.MsgRead")) ? "" : "<img src=\"../../Images/Icons/mail.gif\" align=\"bottom\" hspace=\"5\" border=\"0\">"%><%# DataBinder.Eval(Container, "DataItem.Subject") %>
                    </asp:HyperLink>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Message" HeaderStyle-CssClass="body" ItemStyle-CssClass="body">
                <HeaderStyle CssClass="body" />
                <ItemStyle CssClass="body" />
                <ItemTemplate>
                    <div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 200px;">
                        <label>
                            <%#DataBinder.Eval(Container, "DataItem.Body")%>
                        </label>
                    </div>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField HeaderText="Date" DataField="MsgDate" HtmlEncode="False" DataFormatString="{0:MMM-dd-yyyy hh:mm tt}"
                HeaderStyle-CssClass="date-sent" ItemStyle-CssClass="date-sent">
                <HeaderStyle CssClass="date-sent" />
                <ItemStyle CssClass="date-sent" />
            </asp:BoundField>
            <asp:TemplateField HeaderText="Read" HeaderStyle-CssClass="read" ItemStyle-CssClass="read">
                <HeaderStyle CssClass="read" />
                <ItemStyle CssClass="read" />
                <ItemTemplate>
                    <asp:HyperLink ID="HyperLink3" runat="server" NavigateUrl='<%#"~/Secure/ShowMessage.aspx?FromProfileID="+Eval("FromProfileID")+"&MessageID="+Eval("MessageId")  + "&FromUsername=" + Eval("FromUsername")  %>'>
			<%#DisplayDiscontinuedAsYESorNO(Convert.ToBoolean(Eval("MsgRead")))%>
                    </asp:HyperLink>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Replied" HeaderStyle-CssClass="replied" ItemStyle-CssClass="replied">
                <HeaderStyle CssClass="replied" />
                <ItemStyle CssClass="replied" />
                <ItemTemplate>
                    <asp:HyperLink ID="HyperLink4" runat="server" NavigateUrl='<%#"~/Secure/ShowMessage.aspx?FromProfileID="+Eval("FromProfileID")+"&MessageID="+Eval("MessageId")  + "&FromUsername=" + Eval("FromUsername")  %>'>
			<%#DisplayDiscontinuedAsYESorNO(Convert.ToBoolean(Eval("MsgReplied")))%>
                    </asp:HyperLink>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <div class="clear">
    </div>
    <asp:HiddenField ID="HiddenField1" runat="server" Value="0" />
    <asp:Button ID="btnDelete" runat="server" Text="Delete Checked Records" OnClientClick="return ConfirmDelete();"
        OnClick="btnDelete_Click" />
    <br />
    (* Note: Message(s) will be automatically deleted after 30 days from the received
    date)
    <br />

Open in new window

How can I merge the headers from the table into the following:
<table cellpadding="0" cellspacing="0" class="mbx" style="margin-top: 0;">
    <tr>
        <th class="status" style="text-align: center">
            ?
        </th>
        <th class="cbox" style="text-align: center">
            <asp:CheckBox ID="chkAll" runat="server" onclick="checkAll(this);" />
        </th>
        <th class="sender">
            <asp:Label ID="lblFrom" runat="server" Text="Label"></asp:Label>
        </th>
        <th class="title">
            <asp:Label ID="lblSubject" runat="server" Text="Label"></asp:Label>
        </th>
        <th class="date">
            <asp:Label ID="lblDate" runat="server" Text="Label"></asp:Label>
        </th>
        <th class="read">
            <asp:Label ID="lblRead" runat="server" Text="Label"></asp:Label>
        </th>
    </tr>
</table>
<asp:GridView ID="Inbox" runat="server" DataKeyNames="pmessageid" GridLines="None"
    OnPageIndexChanging="OnPaging" OnRowDataBound="Inbox_RowDataBound" Height="20px"
    HorizontalAlign="Center" VerticalAlign="Middle" AllowPaging="true" AllowSorting="true"
    EmptyDataText="No data available." PageSize="5" AutoGenerateColumns="false" CssClass="customers-grid">
    <AlternatingRowStyle Height="25px" HorizontalAlign="Center" BackColor="#D5E5FC" VerticalAlign="Middle" />
    <Columns>
        <asp:TemplateField HeaderText="Delete">
            <HeaderStyle CssClass="delete-member"></HeaderStyle>
            <ItemStyle CssClass="delete-member" Wrap="False"></ItemStyle>
            <HeaderTemplate>
                <asp:CheckBox ID="chkAll" runat="server" onclick="checkAll(this);" />
            </HeaderTemplate>
            <ItemTemplate>
                <asp:CheckBox ID="chk" runat="server" onclick="Check_Click(this)" />
            </ItemTemplate>
        </asp:TemplateField>


        <asp:TemplateField>
            <HeaderStyle CssClass="from-pic"></HeaderStyle>
            <ItemStyle CssClass="from-pic" Wrap="False"></ItemStyle>
            <ItemTemplate>
                <br />
                <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#"~/Secure/ShowMessage.aspx?FromProfileID="+Eval("FromProfileID")+"&PMessageID="+Eval("PMessageId")  + "&FromUsername=" + Eval("FromUser")  %>'>
                <asp:Image ID="MainPicID" BorderWidth="2" BorderColor="Silver" Style="vertical-align: middle"
                    class="srpic" runat="server" />
                 </asp:HyperLink><br />
                 <%#DataBinder.Eval(Container, "DataItem.FromUser")%>
                <asp:HiddenField ID="hiddenImgID" runat="server" Value='<%#DataBinder.Eval(Container,"DataItem.FromProfileID") %>' />
            </ItemTemplate>
        </asp:TemplateField>

        <asp:TemplateField HeaderText="Subject" HeaderStyle-CssClass="subject" ItemStyle-CssClass="subject">
            <HeaderStyle CssClass="subject" />
            <ItemStyle CssClass="subject" />
            <ItemTemplate>
                <%--<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%#"~/Secure/ShowMessage.aspx?FromProfileID="+Eval("FromProfileID")+"&MessageID="+Eval("MessageId") + "&FromUsername=" + Eval("FromUsername") %>' >--%>
                <%# Convert.ToBoolean(DataBinder.Eval(Container, "DataItem.IsRead")) ? "" : "<img src=\"../../Images/Icons/mail.gif\" align=\"bottom\" hspace=\"5\" border=\"0\">"%><%# DataBinder.Eval(Container, "DataItem.Subject") %>
                <%--</asp:HyperLink>--%>
            </ItemTemplate>
        </asp:TemplateField>
        
        <asp:TemplateField HeaderText="Message" HeaderStyle-CssClass="body" ItemStyle-CssClass="body">
            <HeaderStyle CssClass="body" />
            <ItemStyle CssClass="body" />
            <ItemTemplate>
                <div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 200px;">
                    <label>
                        <%#DataBinder.Eval(Container, "DataItem.Body")%>
                    </label>
                </div>
            </ItemTemplate>
        </asp:TemplateField>


        <asp:TemplateField HeaderText="Date" HeaderStyle-CssClass="date-sent" ItemStyle-CssClass="date-sent">
            <HeaderStyle CssClass="date-sent" />
            <ItemStyle CssClass="date-sent" />
            <ItemTemplate>
                <%# String.Format("{0:MMM-dd-yyyy HH:mm:ss tt}", ((System.Data.DataRowView)Container.DataItem)["Created"])%>
            </ItemTemplate>
        </asp:TemplateField>

        <asp:TemplateField HeaderText="Read" HeaderStyle-CssClass="read" ItemStyle-CssClass="read">
            <HeaderStyle CssClass="read" />
            <ItemStyle CssClass="read" />
            <ItemTemplate>
                <%--  <asp:HyperLink ID="HyperLink3" runat="server" NavigateUrl='<%#"~/Secure/ShowMessage.aspx?FromProfileID="+Eval("FromProfileID")+"&MessageID="+Eval("MessageId")  + "&FromUsername=" + Eval("FromUsername")  %>'>--%>
                <%#DisplayDiscontinuedAsYESorNO(Convert.ToBoolean(Eval("IsRead")))%>
                <%--</asp:HyperLink>--%>
                <asp:Label runat="server" ID="UserPMessageID" Visible="false" Text='<%# DataBinder.Eval(Container.DataItem,"UserPMessageID") %>' />
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>
<div class="clear">
</div>
<asp:HiddenField ID="hfCount" runat="server" Value="0" />
<asp:Button ID="btnDelete" runat="server" Text="Delete Checked Records" OnClientClick="return ConfirmDelete();"
    OnClick="btnDelete_Click" />
<br />
(* Note: Message(s) will be automatically deleted after 30 days from the received
date)
<br />

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Dhanasekaran Sengodan
Dhanasekaran Sengodan
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
k