473,320 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

v2 - GridView - UserControl .ascx - Problem

Hi,

I have the following source code:

<%@ Register tagprefix="my" tagname="tcontrol" Src="article_small.ascx" %>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$
ConnectionStrings:ShopConnectionString %>" SelectCommand="SELECT
AricleNumber FROM Articles;"></asp:SqlDataSource>
<asp:GridView ID="List1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<my:tcontrol runat=server ArticleNumber=<%# Eval("ArticleNumber") %> />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

With this I get the following errormessage:
"Databinding methods such as Eval(), XPath(), and Bind() can only be used
in
the context of a databound control."

But how can I realize that what I want? Is there a workaround?

Thanks,

Alex

Dec 13 '05 #1
4 7013
Hi Alexander,

It has to do with what your user control is doing. You might want to post
the code in your user control.

I met that error when a dropdown list within FormView caused a postback to
change the values of another dropdownlist within the templated control. I
solved it by removing the databind on the dependent list:
http://www.webswapp.com/CodeSamples/...FormView1.aspx

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Alexander Widera" wrote:
Hi,

I have the following source code:

<%@ Register tagprefix="my" tagname="tcontrol" Src="article_small.ascx" %>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$
ConnectionStrings:ShopConnectionString %>" SelectCommand="SELECT
AricleNumber FROM Articles;"></asp:SqlDataSource>
<asp:GridView ID="List1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<my:tcontrol runat=server ArticleNumber=<%# Eval("ArticleNumber") %> />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

With this I get the following errormessage:
"Databinding methods such as Eval(), XPath(), and Bind() can only be used
in
the context of a databound control."

But how can I realize that what I want? Is there a workaround?

Thanks,

Alex

Dec 13 '05 #2
Yes, there was an "illegal" DataBind(). But now I have the Problem, that
the
data is not bound. I get empty <div>-tags, where should be content.

the control looks like that:
<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="article_small.ascx.cs" Inherits="shop_ArticleSmall" %>

<script runat="server" >

public Article article;

public string ArticleNumber {

set { article = new Article(value); }

get { return article.Articlenumber; }

}

</script>
<div class="ArticleSmall">

<div class="ArticleSmallNew" runat="server"> <%# article.ArticleNumber %>
</div>

<div class="ArticleSmallTitle"> <%# article.Title %> </div>

</div>
Perhaps it has something to do with the public in "public Article article"
.... but if I use private then I get the error "'shop_ArticleSmall.artikel'
is inaccessible due to its protection level"

Can someone help me?
Perhaps the solution is allready in
http://www.webswapp.com/CodeSamples/...pnet20\FormVie
w1.aspx
but I don't get it work.

Please help.

Thanks,

alex

"Phillip Williams" <Ph**************@webswapp.com> schrieb im Newsbeitrag
news:A2**********************************@microsof t.com...
Hi Alexander,

It has to do with what your user control is doing. You might want to post the code in your user control.

I met that error when a dropdown list within FormView caused a postback to change the values of another dropdownlist within the templated control. I solved it by removing the databind on the dependent list:
http://www.webswapp.com/CodeSamples/...FormView1.aspx

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Alexander Widera" wrote:
Hi,

I have the following source code:

<%@ Register tagprefix="my" tagname="tcontrol" Src="article_small.ascx"
%>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$
ConnectionStrings:ShopConnectionString %>" SelectCommand="SELECT
AricleNumber FROM Articles;"></asp:SqlDataSource>
<asp:GridView ID="List1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<my:tcontrol runat=server ArticleNumber=<%# Eval("ArticleNumber") %> />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

With this I get the following errormessage:
"Databinding methods such as Eval(), XPath(), and Bind() can only be used in
the context of a databound control."

But how can I realize that what I want? Is there a workaround?

Thanks,

Alex


Dec 14 '05 #3
oh, i forgot:
Article is a selfmade class.... it collects some data ... article.Title and
article.ArticleNumber are returning string values.

"Alexander Widera"
<aw**@hrz.tu-chemnitz.de-novaliddomainpleasedeletethispart.de> schrieb im
Newsbeitrag news:Oq**************@TK2MSFTNGP15.phx.gbl...
Yes, there was an "illegal" DataBind(). But now I have the Problem, that
the
data is not bound. I get empty <div>-tags, where should be content.

the control looks like that:
<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="article_small.ascx.cs" Inherits="shop_ArticleSmall" %>

<script runat="server" >

public Article article;

public string ArticleNumber {

set { article = new Article(value); }

get { return article.Articlenumber; }

}

</script>
<div class="ArticleSmall">

<div class="ArticleSmallNew" runat="server"> <%# article.ArticleNumber %>
</div>

<div class="ArticleSmallTitle"> <%# article.Title %> </div>

</div>
Perhaps it has something to do with the public in "public Article article"
... but if I use private then I get the error "'shop_ArticleSmall.artikel'
is inaccessible due to its protection level"

Can someone help me?
Perhaps the solution is allready in
http://www.webswapp.com/CodeSamples/...pnet20\FormVie
w1.aspx
but I don't get it work.

Please help.

Thanks,

alex

"Phillip Williams" <Ph**************@webswapp.com> schrieb im Newsbeitrag
news:A2**********************************@microsof t.com...
Hi Alexander,

It has to do with what your user control is doing. You might want to

post
the code in your user control.

I met that error when a dropdown list within FormView caused a postback

to
change the values of another dropdownlist within the templated control.

I
solved it by removing the databind on the dependent list:
http://www.webswapp.com/CodeSamples/...FormView1.aspx

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Alexander Widera" wrote:
Hi,

I have the following source code:

<%@ Register tagprefix="my" tagname="tcontrol" Src="article_small.ascx"
%>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$
ConnectionStrings:ShopConnectionString %>" SelectCommand="SELECT
AricleNumber FROM Articles;"></asp:SqlDataSource>
<asp:GridView ID="List1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<my:tcontrol runat=server ArticleNumber=<%# Eval("ArticleNumber") %> />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

With this I get the following errormessage:
"Databinding methods such as Eval(), XPath(), and Bind() can only be used in
the context of a databound control."

But how can I realize that what I want? Is there a workaround?

Thanks,

Alex


Dec 14 '05 #4
Well, thanks for help ... I found the error myself ... it was a completely
other problem.

Case closed

"Alexander Widera"
<aw**@hrz.tu-chemnitz.de-novaliddomainpleasedeletethispart.de> schrieb im
Newsbeitrag news:uy**************@TK2MSFTNGP15.phx.gbl...
oh, i forgot:
Article is a selfmade class.... it collects some data ... article.Title
and article.ArticleNumber are returning string values.

"Alexander Widera"
<aw**@hrz.tu-chemnitz.de-novaliddomainpleasedeletethispart.de> schrieb im
Newsbeitrag news:Oq**************@TK2MSFTNGP15.phx.gbl...
Yes, there was an "illegal" DataBind(). But now I have the Problem, that
the
data is not bound. I get empty <div>-tags, where should be content.

the control looks like that:
<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="article_small.ascx.cs" Inherits="shop_ArticleSmall" %>

<script runat="server" >

public Article article;

public string ArticleNumber {

set { article = new Article(value); }

get { return article.Articlenumber; }

}

</script>
<div class="ArticleSmall">

<div class="ArticleSmallNew" runat="server"> <%# article.ArticleNumber
%>
</div>

<div class="ArticleSmallTitle"> <%# article.Title %> </div>

</div>
Perhaps it has something to do with the public in "public Article
article"
... but if I use private then I get the error
"'shop_ArticleSmall.artikel'
is inaccessible due to its protection level"

Can someone help me?
Perhaps the solution is allready in
http://www.webswapp.com/CodeSamples/...pnet20\FormVie
w1.aspx
but I don't get it work.

Please help.

Thanks,

alex

"Phillip Williams" <Ph**************@webswapp.com> schrieb im Newsbeitrag
news:A2**********************************@microsof t.com...
Hi Alexander,

It has to do with what your user control is doing. You might want to

post
the code in your user control.

I met that error when a dropdown list within FormView caused a postback

to
change the values of another dropdownlist within the templated control.

I
solved it by removing the databind on the dependent list:
http://www.webswapp.com/CodeSamples/...FormView1.aspx

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Alexander Widera" wrote:

Hi,

I have the following source code:

<%@ Register tagprefix="my" tagname="tcontrol" Src="article_small.ascx"
%>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$
ConnectionStrings:ShopConnectionString %>" SelectCommand="SELECT
AricleNumber FROM Articles;"></asp:SqlDataSource>
<asp:GridView ID="List1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<my:tcontrol runat=server ArticleNumber=<%# Eval("ArticleNumber") %> />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

With this I get the following errormessage:
"Databinding methods such as Eval(), XPath(), and Bind() can only be

used
in
the context of a databound control."

But how can I realize that what I want? Is there a workaround?

Thanks,

Alex



Dec 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sascha | last post by:
Hi there, I searched carefully through the web before finally deciding to post this message, because I could not find a solution for my problem. Hopefully someone will have a hint or explanation...
26
by: onearth | last post by:
Hello I already managed to add a dynamic DetailView under a row of Gridview if a user presses the row with the mouse... Is it possible to add under it a table(or even better load a simple...
12
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control...
1
by: Giovanni | last post by:
Dear Friends/Gurus, I have exhausted myself and have yet no solution to the following: I have an ASP.NET 2.0 Survey type application. On a page, I have placed a GridView which is bound to an...
0
by: John Smith | last post by:
ASP.Net 2.0 / C# / IIS 6 I have 2 pages. The master page consists of a tabbed menu created using the Menu and MultiView controls. Something like this: ...
0
by: John Smith | last post by:
If anyone can help, I would very muchly appreciate it. I have a main page that uses the .net 2.0 menu control with the multiview controls as the menu choices. This works fine. One of the menu...
1
by: syl | last post by:
Hello I am trying to create a "easy to use" gridview with filters (dropdownlist in headers), sorting...and much more.... In order to do that, i prefer to use a objectdatasource (ODS) beacause...
1
by: Nathan Sokalski | last post by:
I am revieving the following error for one of my controls when loading any pages that use it: Server Error in '/exposure/app' Application....
2
by: acadam | last post by:
In my application I have a usercontrol called "base" with a panel called "pnl1"; in "pnl1" I put my usercontrol. Now I would like to have 2 possibilities: from "base" to load another control...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.