Monday, February 6, 2012

Grid View in C#.NET

 <asp:GridView ID="GridViewPublisher" runat="server" AllowPaging="True"
                AutoGenerateColumns="False" BorderColor="#ee2449" BorderStyle="Solid" BorderWidth="1px"
                CellPadding="0" DataKeyNames="pk_SuppID,AmpsPublisherCode,Dscription" Font-Bold="False" ShowFooter="true"
                GridLines="Horizontal" SkinID="gridviewSkin" Width="100%" OnRowEditing="GridViewPublisher_RowEditing"
                OnRowUpdated="GridViewPublisher_RowUpdated" OnRowCancelingEdit="GridViewPublisher_RowCancelingEdit"
                OnRowUpdating="GridViewPublisher_RowUpdating" PageSize="5" OnPageIndexChanging="GridViewPublisher_PageIndexChanging">
                <RowStyle BackColor="White" ForeColor="Black" BorderColor="Black" VerticalAlign="Top" />
                <Columns>
                    <asp:TemplateField HeaderText="Publisher Code" SortExpression="Publisher Code">
                        <ItemTemplate>
                            <div style=" padding-left: 5px; font-size: 11pt">
                                <nobr>
                                      <asp:Label ID="lblamppublishercode" runat="server" ToolTip='<%# Bind("AmpsPublisherCode")%>' Text='<%# Eval("AmpsPublisherCode") %>' />
                                 </nobr>
                            </div>
                        </ItemTemplate>
                        <HeaderStyle CssClass="headermiddle" HorizontalAlign="Left"/>
                        <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" Wrap="True" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Description" SortExpression="Description">
                        <ItemTemplate>
                            <div style="font-size: 11pt">
                                <nobr>
                                     <asp:Label ID="txtDescription" runat="server" ToolTip='<%# Bind("Dscription")%>' Text='<%# Eval("Dscription") %>' />
                                 </nobr>
                            </div>
                        </ItemTemplate>
                        <HeaderStyle HorizontalAlign="Left" CssClass="gridFont" />
                        <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" Wrap="True" />
                    </asp:TemplateField>
                    <asp:CommandField ButtonType="Image" UpdateImageUrl="~/Images/edit1.png" CancelImageUrl="~/Images/edit1.png"
                        EditImageUrl="~/Images/edit1.png" ShowEditButton="True">
                        <ItemStyle CssClass="CommandButtons" HorizontalAlign="Right"  Wrap="True" />
                    </asp:CommandField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:Label ID="txpipe" runat="server" Text="|" />
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Center" Wrap="True" />
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:ImageButton ID="imgDelete" runat="server" CommandArgument='<%#Eval("pk_SuppID")%>'
                                OnClick="imgDelete_Click" OnClientClick='return confirm("Are you sure you want to delete this entry?");'
                                ImageUrl="~/Images/delete1.png" ToolTip="Delete" />
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Left"  Wrap="True" CssClass="CommandButtons" />
                    </asp:TemplateField>
                </Columns>
                <SelectedRowStyle BackColor="#B097D7" Font-Bold="True" ForeColor="White" />
                <HeaderStyle CssClass="gridheader" />
                <AlternatingRowStyle BackColor="#E4E4E4" />
            </asp:GridView>








No comments:

Post a Comment