Gridview and User Control

S

Stan SR

Hi,

I use a user control within a gridview
Something like this

<asp:GridView DataSourceID="myDatasource" ID="gvList" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Literal runat="server" id="article" Text='<%#
Eval("myArticle")%>' />
<uc:MyControl runat="server" ID="myUC" Url='<%#
Eval("myUrl")%>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>


My UserControl is a control that must control an url to display a picture
(it makes some actions before).
For my test, I just put a literal on the control and add a property

private string _url="";
public string Url
{
get {return _url; }
set {_url=value;}
}

Inside the page Load event (of the user control), I just have
myLiteral.Text=Url;


But when I use <uc:MyControl runat="server" ID="myUC" Url='<%#
Eval("myUrl")%>' />, it seems it doesn't submit the field's value.
If I use <uc:MyControl runat="server" ID="myUC" Url="test" /> I get the test
value for each row of my gridview.

How can I solve this problem ??

Thanks for your help

Stan
 
S

Stan SR

Ooops..
I ve found the solution...
I had to change my setter like this

set {
myLiteral.text=value;
_url=value;
}


It seems it works.

Stan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top