However, I dont want the CsvDataSource class to be "globally" accessible, I just need one web page has its own CsvDataSource.
Hello,
From your codes I guess that you are using Html (aspx codes). And you have to change from "public" to "private" and do code-behind like this in the Page_Load:
MyApp m = new MyApp();
m.Id = xxx;
this.Page.form1.Controls(m);
And how to write the mark up part in .aspx to reference it?
Looks like you add the control in runtime. But how can I bypass the compile time check? This would fail in compile time.
I just want to define the CsvDataSourceControl class in code behind .aspx.cs file, not in app_code folder
Decker Dong - MSFT
Cheng Bao
However, I dont want the CsvDataSource class to be "globally" accessible, I just need one web page has its own CsvDataSource.
Hello,
From your codes I guess that you are using Html (aspx codes). And you have to change from "public" to "private" and do code-behind like this in the Page_Load:
MyApp m = new MyApp();
m.Id = xxx;
this.Page.form1.Controls(m);
Cheng Bao
Member
245 Points
145 Posts
How to Reference custom DataSourceControl in code-behind file?
Jan 03, 2013 10:13 PM|LINK
I have a web page has a data control which want to bind to a customized DataSourceControl class.
I could put the code as
namespace MyApp { public class CsvDataSource : DataSourceControl {...} }into App_Code folder, and reference it in web pages as
<%@ Register TagPrefix="MyApp" Namespace="MyApp" %> ... <asp:gridview id="GridView1" runat="server" allowsorting="True" datasourceid="csv1" /> <MyApp:CsvDataSource id="csv1" runat="server"></MyApp:CsvDataSource>However, I dont want the CsvDataSource class to be "globally" accessible, I just need one web page has its own CsvDataSource.
So, I want to put class CsvDataSource into the code-behind .aspx.cs file, what should I do to reference that datasource class in .aspx?
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: How to Reference custom DataSourceControl in code-behind file?
Jan 05, 2013 12:48 AM|LINK
Hello,
From your codes I guess that you are using Html (aspx codes). And you have to change from "public" to "private" and do code-behind like this in the Page_Load:
MyApp m = new MyApp();
m.Id = xxx;
this.Page.form1.Controls(m);
Cheng Bao
Member
245 Points
145 Posts
Re: How to Reference custom DataSourceControl in code-behind file?
Jan 07, 2013 05:33 PM|LINK
And how to write the mark up part in .aspx to reference it?
Looks like you add the control in runtime. But how can I bypass the compile time check? This would fail in compile time.
I just want to define the CsvDataSourceControl class in code behind .aspx.cs file, not in app_code folder
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: How to Reference custom DataSourceControl in code-behind file?
Jan 10, 2013 02:29 AM|LINK
You can just double click your ascx or aspx and then switch to cs part and then do coding.