本文介绍了如何在C#asp.net中从ASPX页面到ASHX页面访问ASP服务器控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友,
我已经在c#asp.net中使用* .ashx(通用处理程序文件).现在,我想通过.ashx(通用处理程序文件)文件绑定网格视图.现在,例如.通常我们在C#代码后面的代码中绑定网格视图,就像我想通过处理程序ashx文件进行网格视图绑定一样.为此,我该如何实现.
例如.在aspx页面
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
<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>
C#* .cs文件后面的代码.
Code behind C# *.cs file.
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();
谢谢
PBN
Thanks
PBN
推荐答案
这篇关于如何在C#asp.net中从ASPX页面到ASHX页面访问ASP服务器控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!