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