How to pass value to usercontrol property from a datagrid

B

Big George

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>

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


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
 
E

Eliyahu Goldin

Could be it gets overwritten in some other event? Set breakpoints on all
lines that set the property and see what runs when.
 

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,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top