The following is a simple nested GridView
<asp:GridView ID="grid" runat="server" EnableViewState="true" AllowPaging="True" PageSize = "5" AllowSorting="True" AutoGenerateColumns="False" AutoGenerateEditButton="true" AutoGenerateDeleteButton="true" CellPadding="4" DataKeyNames="ProductID" ShowFooter="true">
<Columns>
<asp:TemplateField HeaderText="Product ID" ItemStyle-HorizontalAlign="Center" >
<ItemTemplate>
<asp:Label runat="server" ID="lblProID" Text='<%#Eval("ProductID")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtProID" Text='<%#Eval("ProductID")%>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox runat="server" ID="txtProID" ></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Product Name" ItemStyle-HorizontalAlign="Center" >
<ItemTemplate>
<asp:Label runat="server" ID="lblProName" Text='<%#Eval("ProductName")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtProName" Text='<%#Eval("ProductName")%>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox runat="server" ID="txtProName" ></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Price" ItemStyle-HorizontalAlign="Center" >
<ItemTemplate>
<asp:Label runat="server" ID="lblPrice" Text='<%#Eval("Price")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtPrice" Text='<%#Eval("Price")%>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox runat="server" ID="txtPrice" ></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Quatity" ItemStyle-HorizontalAlign="Center" >
<ItemTemplate>
<asp:Label runat="server" ID="lblQuatity" Text='<%#Eval("Quantity")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtQuantity" Text='<%#Eval("Quantity")%>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox runat="server" ID="txtQuatity" ></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="" ItemStyle-HorizontalAlign="Center" >
<FooterTemplate>
<asp:Button ID="btnInsert" Text="Insert" runat="server" CommandName="Insert" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Hope this helps!
Read more:
Sunday, January 1, 2012
Create a nested GridView control
8:08 AM
Unknown
No comments
0 comments:
Post a Comment