Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to pass value to usercontrol property from a datagrid

Reply
Thread Tools

How to pass value to usercontrol property from a datagrid

 
 
Big George
Guest
Posts: n/a
 
      12-26-2006
Hello,

I've got an aspx webpage with:

- MyUserControl1 (which shows some labels)
- A Panel containing MyUserControl1
- DataGrid, which has a column that when is clicked fires Sub edit_

<asp:datagrid id="MyDataGrid" runat="server" Width="100%"
Visible="True" oneditcommand="edit_">
..................
</asp:datagrid>

</aspanel><aspanel id="MyPanel" runat="server">
<uc1:myUserControl id="myUserControl1"
runat="server"></uc1:myUserControl>
</aspanel>


Protected myUserControl1 As myUserControl

Public Sub edit_(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)

myUserControl1.SomeProperty = "SomeStuff"
MyPanel.Visible = True

End Sub


However, when myUserControl shows up on the webpage, SomeProperty is
null. It doesn't take the value assigned in Sub edit_
Is there any way to assign a value to myUserontrol.SomeProperty when
edit_ is fired?

Because here it works:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
myUserControl1.SomeProperty = "SomeStuff" ' when myUserControl1
shows up, SomeProperty has value "SomeStuff"
End Sub

 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      12-26-2006
Could be it gets overwritten in some other event? Set breakpoints on all
lines that set the property and see what runs when.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin


"Big George" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ps.com...
> Hello,
>
> I've got an aspx webpage with:
>
> - MyUserControl1 (which shows some labels)
> - A Panel containing MyUserControl1
> - DataGrid, which has a column that when is clicked fires Sub edit_
>
> <asp:datagrid id="MyDataGrid" runat="server" Width="100%"
> Visible="True" oneditcommand="edit_">
> .................
> </asp:datagrid>
>
> </aspanel><aspanel id="MyPanel" runat="server">
> <uc1:myUserControl id="myUserControl1"
> runat="server"></uc1:myUserControl>
> </aspanel>
>
>
> Protected myUserControl1 As myUserControl
>
> Public Sub edit_(ByVal sender As Object, ByVal e As
> DataGridCommandEventArgs)
>
> myUserControl1.SomeProperty = "SomeStuff"
> MyPanel.Visible = True
>
> End Sub
>
>
> However, when myUserControl shows up on the webpage, SomeProperty is
> null. It doesn't take the value assigned in Sub edit_
> Is there any way to assign a value to myUserontrol.SomeProperty when
> edit_ is fired?
>
> Because here it works:
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> myUserControl1.SomeProperty = "SomeStuff" ' when myUserControl1
> shows up, SomeProperty has value "SomeStuff"
> End Sub
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Getting a property of a control inside a usercontrol, from another usercontrol Fabiano ASP .Net 2 06-03-2005 09:56 AM
UserControl - Textbox tag property looses value on postback Mike Dole ASP .Net 3 11-17-2004 12:50 AM
how to pass dynamic value to property in usercontrol moid ASP .Net 2 01-23-2004 03:55 PM
Accessing UserControl property value from page control Iain ASP .Net 3 11-18-2003 12:46 AM



Advertisments