How to pass value to usercontrol property from a datagrid

  • Thread starter Thread starter Big George
  • Start date Start date
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
 
Could be it gets overwritten in some other event? Set breakpoints on all
lines that set the property and see what runs when.
 
Back
Top