Export selected rows of gridview to Excel or word in ASP.Net By Using 3-Tier Architecture

Posted by Priyatham under DotNetFunda.Com on 7/1/2013 | Points: 10 | Views : 1504 | Status : [Member] | Replies : 2
Hi friends,I got a situation To Export selected rows of gridview to Excel or word in ASP.Net By Using 3-Tier Architecture.

Can Any One Help Me Plzz

Thanks In Advance..
M.Priyatham

M.priyatham


Responses

Posted by: Allemahesh on: 7/1/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
Dear Priyatham,

You can copy the selected records form grid-view to new data table. Then export this data table to excel or world in asp.net.
Hope this will help you.

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

Posted by: Priyatham on: 7/1/2013 [Member] Starter | Points: 25

Up
0
Down
ArrayList userdetails = new ArrayList();
int index = -1;
foreach (GridViewRow gvrow in gvdetails.Rows)
{
index = (int)gvdetails.DataKeys[gvrow.RowIndex].Value;
bool result = ((CheckBox)gvrow.FindControl("chkSelect")).Checked;
// Check in the Session
if (ViewState["CHECKED_ITEMS"] != null)
userdetails = (ArrayList)ViewState["CHECKED_ITEMS"];
if (result)
{
if (!userdetails.Contains(index))
userdetails.Add(index);
}
else
userdetails.Remove(index);
}
if (userdetails != null && userdetails.Count > 0)
ViewState["CHECKED_ITEMS"] = userdetails;
}
I am Getting exception
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
In the above code plz help me out fof this
Thanks in Advance
M.priyatham

M.priyatham

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

Login to post response