Click here to Skip to main content
15,891,204 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# asp.net. 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
HTML
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"
AllowPaging="true" DataKeyNames="AutoId"
PageSize="5" PagerSettings-Mode="Numeric">
<columns>
<asp:TemplateField HeaderText="Select">
<itemtemplate>
<asp:CheckBox ID="chkSelect" runat="server" />
</itemtemplate>

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

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

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

this.GridView1.DataSourceID = this.SDSForMainGrid.ID;
this.GridView1.DataBind();


Thanks
PBN
Posted
Updated 27-Aug-12 4:02am
v2

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.

http://stackoverflow.com/questions/391130/what-is-a-httphandler-in-asp-net[^]
 
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