473,322 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to pass value to usercontrol property from a datagrid

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

Dec 26 '06 #1
1 1438
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" <jb*****@gmail.comwrote in message
news:11*********************@a3g2000cwd.googlegrou 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>

</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

Dec 26 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dion Heskett | last post by:
How can I pass a Class as a parameter to in a method ? i.e. Private myMethod( string pram1, Classobject as pram2) { Classobject.DataSource = reader; Classobject.DataBind(); }
2
by: moid | last post by:
how to pass dynamic value to property in usercontrol im using this but its not working <uc1:BusinessUnit id="BusinessUnit1" Type='<%# type %>' POID='<%# poid %>'...
2
by: Benedict Teoh | last post by:
I created a dropdownlist containing day, month and year field and expose a property to assign a date. When I call from a aspx page and assign the value, the new date is not displayed until a submit...
12
by: Phil Certain | last post by:
Hi, I'm trying to do something very simple...or at least it should be. I have created a host page (gen.aspx) and a very simple user control (us.ascx). The corresponding code-behind files are...
4
by: louise raisbeck | last post by:
Resending this as own topic as didnt get answer from original. Would be grateful for a response from anyone that knows. Thanks. Hi there, I found your post really helpful..but i wondered if, once...
13
by: Michael Maes | last post by:
Hi, I have a UserControl containing some controls of which one is a ComboBox. All the InternalControls are Private and some are allowed to be accessed through Public Methods. One of the things I...
1
by: Will Gillen | last post by:
I know this has probably been asked before, but I can't seem to find a solid answer in any of the archives. First, before my question, please forgive my limited knowledge of the event lifecycle...
4
by: igotyourdotnet | last post by:
I have a dropdown on my page and I want to define what should be selected in the drop down when the page loads. I have a session variable I'm setting to do this. I can get the selected value and...
1
by: Stephen Barrett | last post by:
I have an application that was originally built with ASP.Net 1.1. We finally got permission to migrate to 2.0. Due to time constraints we migrated the web projects to 2.0 web application...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.