Reputation: 91
Using Visual Studio 2010 with Server Management Studio 2008 I have made a feature through which a teacher can see the results of all students from all years:
By drop down selection it shows data in grid view, with a button for the teacher to see the selection in an Excel sheet. For some selections there is a lot of data so it takes time.
Now my client does not want display of grid view in the page but direct export into Excel based on the selection on drop down.
Can any one help me to do this.. and would it make my page load a little faster?
Upvotes: 0
Views: 432
Reputation: 1888
first write stored procedure in ssms to retrieve the data. It should be like
CREATE PROCEDURE [Retrieveresult] (@selectedfield nvarchar(50))
AS
BEGIN
select * from students where condition=@selectfield
END
then in visualstudio
oConn = new SqlConnection();
oConn.ConnectionString = "your connection string"
SqlCommand command = new SqlCommand("Retrieveresult");
command.CommandType = System.Data.CommandType.StoredProcedure;
oConn.Open();
command.Parameters.Add(new SqlParameter("@selectfield", System.Data.SqlDbType.nvarchar(50)));
command.Parameters["@selectfield"].Value="selected value from gridview"
IDataReader oDr;
oDr=command.executereader();
while(oDr.read())
{
Get the corresponding values in the objects
}
Upvotes: 1