473,947 Members | 15,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Embedded User Control in DataList - Postback Issue

I feel like I'm going to pull out my hair (there's not much left); I've
read almost every online post trying to figure this out. So I started
over with something VERY simple and it still doesn't work ... here we
go. I have a datalist with an embedded user control. My user control
outputs a single string. The first time thru, everything works
perfectly ... on a postback, the datalist gets it's values correctly,
but the user control does NOT get a passed in value ... here is my test
code; it can't be much simpler (I know that this has to do something
with the ordering of events).

-- TestClass.ascx --
<%@ Control Language="VB" AutoEventWireup ="false" ClassName="Test Class"
%>
<script language="VB" runat="server">
Public MyString As String
Private Sub Page_Load(ByVal src As Object, ByVal e As EventArgs)
Handles MyBase.Load
Response.Write( MyString)
End Sub
</script>

-- TestPage.aspx --
<%@ Page Language="VB" AutoEventWireup ="false" Trace="true"%>
<%@ Register TagPrefix="MyTe st" TagName="TestCl ass"
Src="TestClass. ascx" %><html>
<head runat="server">
<script language="VB" runat="server">
Sub Page_Load(ByVal src As Object, ByVal e As EventArgs)
Handles MyBase.Load
If Not IsPostBack Then
Dim dt As New System.Data.Dat aTable
dt.Columns.Add( "name")
Dim dr As System.Data.Dat aRow
dr = dt.NewRow
dr.Item(0) = "First Run"
dt.Rows.Add(dr)
dg.DataSource = dt
dg.DataBind()
End If
End Sub
Sub linkBtn_Click(B yVal sender As Object, ByVal e As EventArgs)
Trace.Warn("Cli cked Button Event")
Dim dt As New System.Data.Dat aTable
dt.Columns.Add( "name")
Dim dr As System.Data.Dat aRow
dr = dt.NewRow
dr.Item(0) = "Second Run"
dt.Rows.Add(dr)
dg.DataSource = dt
dg.DataBind()
End Sub
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:LinkButt on ID="linkBtn" runat="server"
OnClick="linkBt n_Click">Click</asp:LinkButton>
<asp:DataList ID="dg" runat="server" >
<ItemTemplate >
<%# Container.DataI tem("name") %> in datalist
<MyTest:TestCla ss id="lalala" runat="server" MyString = '<%#
Container.DataI tem("name") %>' />
</ItemTemplate>
</asp:DataList>
</form>
</body>
</html>

Can't be much made any more simple ... TestClass takes MyString and
spits it out to Response.Write. Problem:
1) On first run, everything works perfectly
2) Click the "Click" button
3) I get my "Second Run in datalist" line, but MyString in the user
control isn't being rebound. I know that Container.DataI tem HAS a
value and is NOT null.

I don't care about a Viewstate (because I always want to recreate this
control regardless). I don't plan on retrieving any information from
the control (it is just a display control, I'd use an include file like
in PHP or HTML if I could ... we are trying to modularize code rather
than have 1000+ lines in one file)

Please can anyone help!!!!

Rick

Mar 17 '06 #1
0 1575

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

Similar topics

6
1929
by: Mary Kerrigan | last post by:
I have a user control (menu) with a data list: <asp:DataList id="MyList" runat="server"> <ItemTemplate> <asp:hyperlink cssclass="MenuUnselected" id="myLink1" Text='<%# Container.DataItem("Subject") %>' NavigateUrl='<%# "../productlist.aspx?SubjectID=" & Container.DataItem("SubjectID") & "&selection=" & Container.ItemIndex
1
4715
by: wsyeager36 | last post by:
I have a datagrid inside a datalist. The datalist shows parent info and the datagrid shows the child info for that parent. There is a checkbox on each row of the child datagrid. Also inside the datalist is a radiobuttonlist. When this radiobuttonlist is checked, I would like it to iterate thru each row on the child grid and either select or deselct the checkboxes (which are on each row of the child datagrid). In addition, the user can also check...
1
10940
by: bill yeager | last post by:
I have a datagrid control within a datalist control. When I try and do a "Find" on the control, the object comes back with nothing and then my pgm crashes. I am 100% sure that my datagird inside my datalist has an id of "Datagrid3". dgChild comes back with "Nothing" while debugging. Here is my code in the itemdatabound event for the datalist: <code>
2
2317
by: Roman | last post by:
I have built a simple user control that contains 2 buttons, a text box and a dropdownlist. When a button is clicked it sets the visible property of the textbox/dropdownlist and the button. ie the buttons allow me to toggle between the textbox and the dropdownlist. This works fine when the control is placed on the page but when it is placed inside a datalist, ie the itemtemplate, the onclick events for the buttons fire but the visibility...
8
2279
by: David Lozzi | last post by:
Howdy, I have a user control that is a report to display data. On the page the control is inserted in, I have filter options to filter the report. When I try to do something like this, nothing happens. dim filt as string ... build filter string... UserControl.ReportFilter = filt
2
3463
by: Hans Merkl | last post by:
Hi, I am trying to use a user control as EditItemTemplate in a DataList. It loads fine but I can't figure out how to bind to the data of the DataList. Here is what I have got so far: //Page_load of my user control protected void Page_Load(object sender, EventArgs e) { IDataItemContainer DataContainer = this.Parent as
1
4043
by: yoknows | last post by:
Hello .Net Gurus. This is my first post here so I apologize in advance if I have not provided the right information. I hope someone has seen this problem before and can tell me what I am doing wrong. I have simplified the problem with the following example: Using asp.net 2.0, I have a Master page template used on default.aspx. >From within the Content tags on that page I placed a Datalist. It is iterating a User control "Inner" with...
0
2233
by: John Smith | last post by:
I still have not gotten this damn thing figured out and I'm asking for help one last time before I give up on it. I have a user control that contains a paged gridview control. The master page contains a menu control What I want to happen is that, whenever a menu item is selected, the appropriate user control will load. Simple enough? Well, not for me. I finally got the gridview paging and postback issue resolved thanks to...
1
1514
by: Maury | last post by:
Hello, I created two user control, the first manage an object of mine, the second is a DataList in which each Item is the first control...when I click the 'save' button in the first control, the object is saved with new values, but in the list is displayed the old value (until I postBack again) Can someone tell me the right way to manage updates of nested user controls? Thanks
0
9982
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10689
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9886
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8254
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7428
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6113
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6331
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4944
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3541
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.