AutoEventWireup Problem

N

Nitin

I'm using the following code to verify weather the checkbox in the template
column of the datalist1 is checked
'
Sub Button1_Click(sender As Object, e As EventArgs)
cart.text="" Dim i As Integer For i = 0 To productlist.Controls.Count - 1
Dim item As DataListItem = productlist.Controls(i) If item.ItemType =
ListItemType.Item Or item.ItemType = ListItemType.AlternatingItem Then
Dim cb As System.Web.UI.WebControls.CheckBox =
item.FindControl("CheckBox1") 'Checkbox control in the datalist
Dim tb As System.Web.UI.WebControls.TextBox = item.FindControl("TB1")' Text
box control
Dim cod As System.Web.UI.WebControls.Label = item.FindControl("LB1")' Label
control in datalist
If cb.Checked = "True" Then cart.visible ="true"
cart.Text += "["+ cod.Text + "X " + tb.Text+ "]"
End If
end if
next
End Sub

' This is my datalist design
<asp:DataList id="productlist" runat="server" Height="42px"
RepeatColumns="3" RepeatDirection="Horizontal" HorizontalAlign="Center"
width="100%" DataKeyField="Code" GridLines="Both"
ItemStyle-HorizontalAlign="Center">
<ItemStyle horizontalalign="Center"></ItemStyle>
<ItemTemplate>
<asp:HyperLink id="HyperLink1" Target="_blank"
Runat="server" Text="Click to Enlarge"
ImageUrl='<%#string.format("images/th_{0}.jpg",container.dataitem("Code"))%>'
NavigateUrl='<%#string.format("maximage.aspx?SI={0}",container.dataitem("Code"))%>'></asp:HyperLink>
<br />
<asp:Label id="LB1" text='<%#container.dataitem("Code")%>'
runat="server"></asp:Label>
<br />
<asp:CheckBox id="CheckBox1" Runat="server"
Checked="True"></asp:CheckBox>
Quantity:<asp:TextBox id="TB1" Runat="server"
Width="40px"></asp:TextBox>
<br />
</ItemTemplate>
</asp:DataList>

When I set AutoEvent Wireup ="False" then the page_load sub does not run
when i set it to "True" then the Button1_click sub does not run.
After the page load event occurs(autoeventwireup="false") i set
autoeventwireup="true" and refresh the page then every thing seems to work
fine. What do I do?
Thanx
Regards
Nitin
 
A

Aquila Deus

Nitin said:
I'm using the following code to verify weather the checkbox in the template
column of the datalist1 is checked
'
Sub Button1_Click(sender As Object, e As EventArgs)
cart.text="" Dim i As Integer For i = 0 To productlist.Controls.Count - 1
Dim item As DataListItem = productlist.Controls(i) If item.ItemType =
ListItemType.Item Or item.ItemType = ListItemType.AlternatingItem Then
Dim cb As System.Web.UI.WebControls.CheckBox =
item.FindControl("CheckBox1") 'Checkbox control in the datalist
Dim tb As System.Web.UI.WebControls.TextBox = item.FindControl("TB1")' Text
box control
Dim cod As System.Web.UI.WebControls.Label = item.FindControl("LB1")' Label
control in datalist
If cb.Checked = "True" Then cart.visible ="true"
cart.Text += "["+ cod.Text + "X " + tb.Text+ "]"
End If
end if
next
End Sub

' This is my datalist design
<asp:DataList id="productlist" runat="server" Height="42px"
RepeatColumns="3" RepeatDirection="Horizontal" HorizontalAlign="Center"
width="100%" DataKeyField="Code" GridLines="Both"
ItemStyle-HorizontalAlign="Center">
<ItemStyle horizontalalign="Center"></ItemStyle>
<ItemTemplate>
<asp:HyperLink id="HyperLink1" Target="_blank"
Runat="server" Text="Click to Enlarge"
NavigateUrl=' said:
<br />
<asp:Label id="LB1"
text=' said:
runat="server"></asp:Label>
<br />
<asp:CheckBox id="CheckBox1" Runat="server"
Checked="True"></asp:CheckBox>
Quantity:<asp:TextBox id="TB1" Runat="server"
Width="40px"></asp:TextBox>
<br />
</ItemTemplate>
</asp:DataList>

When I set AutoEvent Wireup ="False" then the page_load sub does not run
when i set it to "True" then the Button1_click sub does not run.
After the page load event occurs(autoeventwireup="false") i set
autoeventwireup="true" and refresh the page then every thing seems to work
fine. What do I do?

It's probably a bug. Don't use AutoEventWireup, bind the event handler
by yourself.
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top