ASP.NET - How we can select particular number of row tobe displayed in gridview in asp.net

Asked By akanksha gupta on 19-Feb-13 06:55 AM

<



table>


<



tr>


<



td>




<asp:Label ID="Label12" runat="server" Text="Show"></asp:Label>


 

</



td>


<



td>




<asp:DropDownList ID="DropDownList1" runat="server">




<asp:ListItem>10</asp:ListItem>




<asp:ListItem>20</asp:ListItem>




<asp:ListItem>50</asp:ListItem>




<asp:ListItem>100</asp:ListItem>




<asp:ListItem>All</asp:ListItem>




</asp:DropDownList>


</



td>


</



tr>


</



table>


 

 



<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"




DataKeyNames="SOW_ID" DataSourceID="SqlDataSource1" AllowPaging ="True"




ShowFooter = "True" style="margin-top: 4px" Height="72px"




Width="16px" AllowSorting="True"




onselectedindexchanged="GridView1_SelectedIndexChanged"




OnPageIndexChanged="GridView1_PageIndexChanged" CssClass="mGrid"




PagerStyle-CssClass="pgr"




AlternatingRowStyle-CssClass="alt">




<SortedAscendingHeaderStyle CssClass="sortasc" />




<SortedDescendingHeaderStyle CssClass="sortdesc" />




<Columns>





<asp:TemplateField SortExpression="SOW_ID" >




<HeaderTemplate>SOW ID




</HeaderTemplate>




<ItemTemplate>




<asp:Label ID="LblSOWId" runat="server" Text='<%# Bind("SOW_ID") %>'></asp:Label>




</ItemTemplate>


</



asp:TemplateField>




<asp:TemplateField HeaderText="Project_Name" SortExpression="Project_Name" >




<HeaderTemplate>


SOW Project Name



<asp:DropDownList ID="ddlSOWProject"




DataTextField="Project_Name"




AutoPostBack="true"




OnSelectedIndexChanged="FilterDropDown_IndexChanged"




OnPreRender="SetValue"




DataSourceID="SqlDataSource2" runat="server" Width="120px" Font-Size="11px" />






</HeaderTemplate>




<EditItemTemplate>




<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Project_Name") %>'></asp:TextBox>




</EditItemTemplate>




<ItemTemplate>




<asp:Label ID="Label1" runat="server" Text='<%# Bind("Project_Name") %>'></asp:Label>




</ItemTemplate>


<



FooterTemplate>


<



asp:TextBox ID="txtFName1" runat="server" Width="100px"></asp:TextBox>


</



FooterTemplate>




</asp:TemplateField>


 

<



asp:TemplateField SortExpression="CRNum">




<HeaderTemplate>CRNum




</HeaderTemplate>


<



EditItemTemplate>


<



asp:TextBox ID="txtFName3" Width="100px" runat="server" Text='<%# Bind("CRNum") %>'></asp:TextBox>


</



EditItemTemplate>


<



FooterTemplate>


<



asp:TextBox ID="txtFName4" runat="server" Width="100px"></asp:TextBox>


</



FooterTemplate>


<



ItemTemplate>


<



asp:Label ID="Label2" runat="server" Text='<%# Bind("CRNum") %>'></asp:Label>


</



ItemTemplate>


</



asp:TemplateField>




<asp:TemplateField SortExpression="Start_Date">




<HeaderTemplate>Start Date




</HeaderTemplate>


<



EditItemTemplate>


<



asp:TextBox ID="txtFName5" Width="100px" runat="server" Text='<%# Bind("Start_Date") %>'></asp:TextBox>


</



EditItemTemplate>


<



FooterTemplate>


<



asp:TextBox ID="txtFName6" runat="server" Width="100px"></asp:TextBox>


</



FooterTemplate>


<



ItemTemplate>



<



asp:Label ID="Label3" runat="server" Text='<%# Bind("Start_Date") %>'></asp:Label>


</



ItemTemplate>


</



asp:TemplateField>




<asp:TemplateField SortExpression="End_Date">




<HeaderTemplate>End Date




</HeaderTemplate>


<



EditItemTemplate>


<



asp:TextBox ID="txtFName7" Width="100px" runat="server" Text='<%# Bind("End_Date") %>'></asp:TextBox>


</



EditItemTemplate>


<



FooterTemplate>


<



asp:TextBox ID="txtFName8" runat="server" Width="100px"></asp:TextBox>


</



FooterTemplate>


<



ItemTemplate>


<



asp:Label ID="Label4" runat="server" Text='<%# Bind("End_Date") %>'></asp:Label>


</



ItemTemplate>


</



asp:TemplateField>




<asp:TemplateField SortExpression="SOW_Cost">




<HeaderTemplate>SOW Cost




</HeaderTemplate>


<



EditItemTemplate>


<



asp:TextBox ID="txtFName9" Width="100px" runat="server" Text='<%# Bind("SOW_Cost") %>'></asp:TextBox>


</



EditItemTemplate>


<



FooterTemplate>


<



asp:TextBox ID="txtFName10" runat="server" Width="100px"></asp:TextBox>


</



FooterTemplate>


<



ItemTemplate>


<



asp:Label ID="Label5" runat="server" Text='<%# Bind("SOW_Cost") %>'></asp:Label>


</



ItemTemplate>


</



asp:TemplateField>




<asp:TemplateField SortExpression="Location">




<HeaderTemplate>Location





<asp:DropDownList ID="ddlLocation"




DataTextField="Location"




AutoPostBack="true"




OnSelectedIndexChanged="FilterDropDown_IndexChanged1"




OnPreRender="SetValue1"




DataSourceID="SqlDataSource3" runat="server" Width="120px" Font-Size="11px" />




</HeaderTemplate>




<EditItemTemplate>




<asp:TextBox ID="TxtLocation" runat="server" Text='<%# Bind("Location") %>'></asp:TextBox>




</EditItemTemplate>




<ItemTemplate>




<asp:Label ID="LblLocation" runat="server" Text='<%# Bind("Location") %>'></asp:Label>




</ItemTemplate>


<



FooterTemplate>


<



asp:TextBox ID="txtFName12" runat="server" Width="100px"></asp:TextBox>


</



FooterTemplate>


<



ItemTemplate>


<



asp:Label ID="Label6" runat="server" Text='<%# Bind("Location") %>'></asp:Label>


</



ItemTemplate>


</



asp:TemplateField>




<asp:TemplateField SortExpression="SOW_Status">




<HeaderTemplate>SOW Status




</HeaderTemplate>


<



EditItemTemplate>


<



asp:TextBox ID="txtFName13" Width="100px" runat="server" Text='<%# Bind("SOW_Status") %>'></asp:TextBox>


</



EditItemTemplate>


<



FooterTemplate>


<



asp:TextBox ID="txtFName14" runat="server" Width="100px"></asp:TextBox>


</



FooterTemplate>


<



ItemTemplate>


<



asp:Label ID="Label7" runat="server" Text='<%# Bind("SOW_Status") %>'></asp:Label>


</



ItemTemplate>


</



asp:TemplateField>




<asp:TemplateField SortExpression="Comments">




<HeaderTemplate>Comments




</HeaderTemplate>


<



EditItemTemplate>


<



asp:TextBox ID="txtFName15" Width="100px" runat="server" Text='<%# Bind("Comments") %>'></asp:TextBox>


</



EditItemTemplate>


<



FooterTemplate>


<



asp:TextBox ID="txtFName16" runat="server" Width="100px"></asp:TextBox>


</



FooterTemplate>


<



ItemTemplate>


<



asp:Label ID="Label8" runat="server" Text='<%# Bind("Comments") %>'></asp:Label>


</



ItemTemplate>


</



asp:TemplateField>




<asp:TemplateField SortExpression="Date_Modified">




<HeaderTemplate>Date Modified




</HeaderTemplate>


<



EditItemTemplate>


<



asp:TextBox ID="txtFName17" Width="100px" runat="server" Text='<%# Bind("Date_Modified") %>'></asp:TextBox>


</



EditItemTemplate>


<



FooterTemplate>


<



asp:TextBox ID="txtFName18" runat="server" Width="100px"></asp:TextBox>


</



FooterTemplate>


<



ItemTemplate>


<



asp:Label ID="Label9" runat="server" Text='<%# Bind("Date_Modified") %>'></asp:Label>


</



ItemTemplate>


</



asp:TemplateField>




<asp:TemplateField SortExpression="Date_Created">




<HeaderTemplate>Date Created




</HeaderTemplate>


<



EditItemTemplate>


<



asp:TextBox ID="txtFName19" Width="100px" runat="server" Text='<%# Bind("Date_Created") %>'></asp:TextBox>


</



EditItemTemplate>


<



FooterTemplate>


<



asp:TextBox ID="txtFName20" runat="server" Width="100px"></asp:TextBox>


</



FooterTemplate>


<



ItemTemplate>


<



asp:Label ID="Label10" runat="server" Text='<%# Bind("Date_Created") %>'></asp:Label>


</



ItemTemplate>


</



asp:TemplateField>




<asp:TemplateField SortExpression="SOW_HLE_Coordinator">




<HeaderTemplate>HLE_Coordinator




</HeaderTemplate>


<



EditItemTemplate>


<



asp:TextBox ID="txtFName21" Width="100px" runat="server" Text='<%# Bind("SOW_HLE_Coordinator") %>'></asp:TextBox>


</



EditItemTemplate>


<



FooterTemplate>


<



asp:TextBox ID="txtFName22" runat="server" Width="100px"></asp:TextBox>


</



FooterTemplate>



<



ItemTemplate>


<



asp:Label ID="Label11" runat="server" Text='<%# Bind("SOW_HLE_Coordinator") %>'></asp:Label>


</



ItemTemplate>


</



asp:TemplateField>


 

<



asp:templatefield HeaderText ="Edit">




<itemtemplate >




<asp:linkbutton id="btnEdit" runat="server" commandname="Edit" text='<img src="Images/imagesCACFNOQI.jpg" />' />




</itemtemplate>




<EditItemTemplate>


<



asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update" Text="Update"></asp:LinkButton>


<



asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"></asp:LinkButton>


</



EditItemTemplate>


<



FooterTemplate>


<



asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="AddNew" Text="Add New"></asp:LinkButton>


</



FooterTemplate>


<



ItemTemplate>


<



asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit" Text='<img src="Images/imagesCACFNOQI.jpg" />'></asp:LinkButton>


</



ItemTemplate>




</asp:templatefield>




<asp:TemplateField HeaderText="Delete">




<ItemTemplate >




<asp:LinkButton ID="btnDelete" runat="server" CommandName="Delete" Text='<img src="Images/untitled.bmp" />'>




</asp:LinkButton>




</ItemTemplate>




</asp:TemplateField>




</Columns>



 

 



<SortedAscendingHeaderStyle BackColor="#506C8C" />




<SortedDescendingHeaderStyle BackColor="#6F8DAE" />


</



asp:GridView>