<%@ Page Title="" Language="C#" MasterPageFile="~/mstr2.Master" AutoEventWireup="true" CodeBehind="AdminManagePosts.aspx.cs" Inherits="CarGallery.AdminManagePosts" %>
<%@ MasterType VirtualPath="~/mstr2.Master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphMain" runat="server">
    <script type="text/javascript" src=<%# ResolveUrl("http://code.jquery.com/jquery-latest.min.js") %> ></script>
<script type = "text/javascript">

    function checkAll(objRef) {

        var GridView = objRef.parentNode.parentNode.parentNode;

        var inputList = GridView.getElementsByTagName("input");

        for (var i = 0; i < inputList.length; i++) {

            var row = inputList[i].parentNode.parentNode;

            if (inputList[i].type == "checkbox" && objRef != inputList[i]) {

                if (objRef.checked) {
                    inputList[i].checked = true;
                }

                else {
                    inputList[i].checked = false;
                }
            }
        }
    }

</script>

    <div align="right" style="width:100%;max-width:100%;min-width:10%; height:auto;">
        <div align="center" style="color:White;background-color:#507CD1;font-weight:bold; height: 45px;vertical-align:middle;font-size:16px"><br />Manage Posts</div>
        <div align="left" style="height:40px;background-color:white;color:black;margin-top:10px">
            <br />        
            &nbsp; Filter : <asp:DropDownList ID="drdlFilter" runat="server" Width="200px" AutoPostBack="true" OnSelectedIndexChanged="drdlFilter_SelectedIndexChanged">
                <asp:ListItem Text="All" Value="0"/>
                <asp:ListItem Text="Slide Allowed" Value="1"/>
                <asp:ListItem Text="Slide Not Allowed" Value="2"/>
                <asp:ListItem Text="Comments Allowed" Value="3"/>
                <asp:ListItem Text="Comments Not Allowed" Value="4"/>
                                   </asp:DropDownList>

            &nbsp;&nbsp;&nbsp;&nbsp; Page Size : <asp:DropDownList AutoPostBack="true" OnSelectedIndexChanged="drdnPageSize_SelectedIndexChanged" ID="drdnPageSize" runat="server" Width="50px">
                <asp:ListItem Text="5" Value="5"/>
                <asp:ListItem Text="10" Value="10"/>
                <asp:ListItem Text="15" Value="15"/>
                <asp:ListItem Text="20" Value="20"/>
                <asp:ListItem Text="30" Value="30"/>
                <asp:ListItem Text="50" Value="50"/>
                                   </asp:DropDownList>   
        </div>
        
        <div style="width:auto;margin-top:10px;background-color:#507CD1">
            <div style="height:15px"></div>
            <asp:GridView ID="gridView1" style="width:100%;" runat="server" Font-Size="14px" AutoGenerateColumns="False" DataKeyNames="id" OnRowCommand="gridView1_RowCommand" OnRowEditing="gridView1_RowEditing" AllowPaging="True" PageSize="5" OnPageIndexChanging="gridView1_PageIndexChanging" ForeColor="#333333">
                    <AlternatingRowStyle BackColor="White" />
                    <Columns>
                        <asp:TemplateField HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Top">
                            <HeaderTemplate>
                                <asp:CheckBox ID="checkAll" Text="" runat="server" onclick = "checkAll(this);" />
                            </HeaderTemplate>
                            <ItemTemplate>
                                <br />
                                    <asp:CheckBox ID="chkBatchAction" style="margin-left:8px" onclick = "Check_Click(this)" runat="server"/>
                                    
                            </ItemTemplate>
                            <HeaderStyle Width="30px" />
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="#" HeaderStyle-HorizontalAlign="Left">
                            <ItemTemplate>
                                <br />
                                    <asp:Label ID="lblNo" runat="server" Text='<%#Bind("no") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle/>
                        </asp:TemplateField>

                        <asp:TemplateField>
                            <ItemTemplate>
                                <br />
                                <br />
                                    <asp:Image runat="server" ID="img" ImageUrl='<%#Bind("thumb") %>' style="width:150px;height:auto;margin-top:-20px" AlternateText='<%#Bind("title") %>' />
                                <br />
                                <br />
                            </ItemTemplate>
                            <HeaderStyle/>
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Title" HeaderStyle-HorizontalAlign="Left">
                            <ItemTemplate>
                                <br />
                                    <asp:Label ID="lblTitle" runat="server" Text='<%#Bind("title") %>'></asp:Label>
                                    <asp:HiddenField ID="hid" runat="server" Value= '<%#Bind("id") %>' />
                            </ItemTemplate>
                            <HeaderStyle/>
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Visits">
                            <ItemTemplate>
                                <br />
                                <center>
                                <asp:Label ID="lblVisits" runat="server" Text='<%#Bind("visits") %>'></asp:Label>
                                    </center>
                            </ItemTemplate>
                            <HeaderStyle Font-Bold="False" Font-Size="Small" />
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Date and Time">
                            <ItemTemplate>
                                <br />
                                <center>
                                <asp:Label ID="lblDateTime" runat="server" Text='<%#Bind("datetime") %>'></asp:Label>
                                    </center>
                            </ItemTemplate>
                            <HeaderStyle Font-Bold="False" Font-Size="Small" />
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Is Slide ?">
                            <ItemTemplate>
                                <br />
                                <center>
                                    
                                    <asp:ImageButton ID="lbtnSlide" runat="server" ImageUrl='<%# Bind("slide") %>' CommandArgument='<%# Bind("id") %>'  CommandName="Slide" />
                                </center>
                            </ItemTemplate>
                            <HeaderStyle Font-Bold="False" Font-Size="Small" />
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Comments">
                            <ItemTemplate>
                                <br />
                                <center>
                                    <asp:ImageButton ID="lbtnComment" runat="server" ImageUrl='<%# Bind("comment") %>' CommandArgument='<%# Bind("id") %>'  CommandName="Comment" />
                                    &nbsp;&nbsp<asp:Label ID="lblComments" runat="server" Text='<%#Bind("comments") %>'></asp:Label>

                                </center>
                            </ItemTemplate>
                            <HeaderStyle Font-Bold="False" Font-Size="Small" />
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Operations">
                            <ItemTemplate>
                                <br />
                                <table style="width: 100%">
                                    <tr>
                                        <td align="left" style="width:18px">
                                            <asp:LinkButton ID="lbtnEdit" runat="server" CommandArgument='<%# Bind("id") %>'  CommandName="Edit"><img src="../img/btn_edit.png" /></asp:LinkButton>
                                        </td>
                                        <td align="center" style="width:18px">
                                            <asp:LinkButton ID="lbtnDelete" runat="server" CommandArgument='<%# Bind("id") %>'  CommandName="Delete"><img src="../img/btn_delete.png" /></asp:LinkButton>
                                        </td>
                                        <td align="center" style="width:18px">
                                            <asp:LinkButton ID="lblView" runat="server" CommandArgument='<%# Bind("id") %>'  CommandName="View" OnClientClick="document.forms[0].target = '_blank';"><img src="../img/btn_view.png" /></asp:LinkButton>
                                        </td>

                                    </tr>
                                </table>
                            </ItemTemplate>
                        </asp:TemplateField>

                    </Columns>
                    <EditRowStyle BackColor="#2461BF" />
                    <FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True" />
                    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" Height="30px" />
                    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="center" Height="25px" Font-Size="18px" />
                    <RowStyle BackColor="#EFF3FB" />
                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                    <SortedAscendingCellStyle BackColor="#F5F7FB" />
                    <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                    <SortedDescendingCellStyle BackColor="#E9EBEF" />
                    <SortedDescendingHeaderStyle BackColor="#4870BE" />
                </asp:GridView>
         </div>
        <div style="width:auto;margin-top:10px;background-color:#507CD1">
                        &nbsp;Batch Operation : &nbsp; 
                                <asp:DropDownList ID="drdlBatchAction" runat="server" Width="150px">
                                    <asp:ListItem Text="Enable Slide" Value="0"/>
                                    <asp:ListItem Text="Disable Slide" Value="1"/>
                                    <asp:ListItem Text="Enable Comment" Value="2"/>
                                    <asp:ListItem Text="Disable Comment" Value="3"/>
                                    <asp:ListItem Text="Delete Posts" Value="4"/>
                                </asp:DropDownList>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:Button id="btnBatchAction" Width="100px" Text="RUN" runat="server" OnClick="btnBatchAction_Click"></asp:Button>
                    </div>
        </div>
</asp:Content>
