the gridview i have dropdown

Posted by Naveenmanam under ASP.NET on 5/4/2010 | Views : 1552 | Status : [Member] | Replies : 3
hi I have Gridview ,Above the gridview i have dropdown list in that 25,50,100 are data items are there,if user select 25 means in gridview only 25 records are display and if user select 50 means ,50 records to be displaied,Please give code for this task

NaveenKumar


Responses

Posted by: Diya0076 on: 5/4/2010 [Member] Starter

Up
0
Down
hi.. i think you should use the the dorodownlist's selectedIndexChanged event ..

based one the value of dropdown change the pagesize of the gridview this way..

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)

{
switch (DropDownList1.Text)
{
case "25":
GridView1.PageSize = 25;
break;
case "50":
GridView1.PageSize = 50;
break;
}

}


Naveenmanam, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Er.deepakdalal on: 5/4/2010 [Member] Starter

Up
0
Down
Nice ans. Diya there is another way is to limit the record from the sql query as follows:-

SELECT TOP limit * FROM Table_Name

where limit is the number of records you getting from your dropdownlist

Naveenmanam, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shikharkum on: 5/5/2010 [Member] Starter

Up
0
Down
better use dropdownlist.selectedvalue or dropdownlist.selecteditem to get the selected item and populate the gridview on the basis of this.

Naveenmanam, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response