Click here to Skip to main content
15,608,181 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,

I have used *.ashx (generic handler file) in c# Now I want to bind grid view though .ashx (generic handler file)file. Now Eg. Normally we are binding grid view in code behind C# code like that I want do grid view binding though handler ashx file. To do this how I can achieve this.

Eg. In aspx page
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"
AllowPaging="true" DataKeyNames="AutoId"
PageSize="5" PagerSettings-Mode="Numeric">
<asp:TemplateField HeaderText="Select">
<asp:CheckBox ID="chkSelect" runat="server" />

<asp:BoundField HeaderText="Last Name" DataField="LastName" />
<asp:TemplateField HeaderText="Is Active?">
<%# Eval("Active").ToString().Equals("True") ? "Yes" : "No" %>

Code behind C# *.cs file.
this.GridView1.DataSourceID = this.SDSForMainGrid.ID;

//Normally we binding in c# .cs code  
// similarly in *.ashx file

this.GridView1.DataSourceID = this.SDSForMainGrid.ID;

Updated 27-Aug-12 4:02am

1 solution

The HTTPhandlers for .ashx and .aspx requests are different. These are extension based handlers and the requests are diverted to a particular handler depending upon the extension and are processes differently. You can use both of them but cannot mix them.[^]
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