Click here to Skip to main content
15,903,203 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I got my Database values in Gridview and I have implemented the paging, Then I am importing data to excelsheet, I have done all these things and now I want to add more functionality as follows.

I have added two radio buttons that are "Top 100 rows" and "Show All". I want to show top 100 rows when user select the appropriate radio button and show whole bunch of data on selection of other radio button.

Can anyone one provide me with some idea??
Posted
Updated 3-Nov-13 23:10pm
v2
Comments
Thomas ktg 4-Nov-13 4:41am    
Do you mean that you want to export Top 100 rows when user selects the Radio Button "Select top 100 rows"?
chahthuranga 4-Nov-13 4:56am    
yes

Below is the simple code to make you understand how to fetch Top 100 records. This is actually an idea to make it clear how you can do to fetch Top 100 rows.

C#
private DataTable GetDatasource()
{
    DataTable dtable = new DataTable();
    string _Query = string.Empty;
    _Query = "SELECT TOP 100 * FROM Customers";
    //Do the other stuffs here to fetch Top 100 records from Database.
    return dtable;
}

// On Radion Button Click event 
protected void btnRadioButton1_Click(object sender, EventArgs e)
{
   //Here the dtable will have Top 100 rows from Database. If you want to show this in the gridview assign the dtable to the gridview datasource.
   DataTable dtable = GetDatasource();
   //Export the dtable record to excel
   GridViewExportUtil.Export("Customers.xls", dtable);
}

Hope it helps.
 
Share this answer
 
write a sql query for raddio button1 select event
i.e string conString="select top 100 [columnsname]or [*] from tablename";
..
for radiobuttion2:
string conString="select [columnsname]or [*] from tablename"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900