I have a LinkButton which fires an OnClick event to
update some Labels; however, after the first firing of OnClick, it won't
fire again when I click another (or the same) LinkButton which runs the
same OnClick event. (It's a list of people, each a LinkButton, and
clicking on one brings up their details)
If I leave the page a few minutes, it will work again, almost as if
whatever was preventing OnClick firing timed-out. Of course, this won't
be any use to the users!
This is my ASP.NET code for the LinkButtons (encapsulated in a DataList):
<asp:DataList ID="DataList1" runat="server" DataKeyField="AdmissionNumber"> <ItemTemplate> <asp:CheckBox ID="CheckBox" runat="server" OnCheckedChanged="Checkbox_CheckedChanged" ViewState="true"/> <asp:LinkButton ID="LinkButton" runat="server" OnClick="LinkButton_OnClick"> <asp:HiddenField ID="hfAdmissionNumber" Value='<%# Eval("AdmissionNumber") %>' runat="server"/> <asp:Label ID="CalledLabel" runat="server" Text='<%# Eval("Called") %>' /> <asp:Label ID="SurnameLabel" runat="server" Text='<%# Eval("Surname") %>' /> </asp:LinkButton><br /><br /> </ItemTemplate></asp:DataList>
In the Page_Load event in the C# code behind, the following populates the DataList:
connection.Open();SqlDataReader reader = command.ExecuteReader();DataList1.DataSource = reader;DataList1.DataBind();connection.Close()
And this is the OnClick event:
protected void LinkButton_OnClick(object sender, EventArgs e){ LinkButton l = (LinkButton)sender; HiddenField hfv = (HiddenField)l.Parent.FindControl("hfAdmissionNumber"); using (SqlConnection connection = new SqlConnection("Data Source=pastonmis01inform;Initial Catalog=2009;Integrated Security=True")) { using (SqlCommand command = new SqlCommand("xProcSportNotParticipantDetails",connection)) { connection.Open( ); command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@AdmissionNumber", Int32.Parse(hfv.Value)); SqlDataReader reader = command.ExecuteReader(); reader.Read(); lTitle.Text = reader.GetValue(0).ToString(); lSurname.Text = reader.GetValue(1).ToString(); lForename.Text = reader.GetValue(2).ToString(); lCalled.Text = reader.GetValue(3).ToString(); lDoB.Text = reader.GetValue(4).ToString().Substring(0,10); lSex.Text = reader.GetValue(5).ToString(); reader.Close(); } connection.Close(); }}
All the connections work, the data is retrieved, etc, so everything
except the OnClick firing works. I've done a search of the internet and the forum, and
found this seems to have been a long-standing problem since the first
ASP.NET, but there is no solution for ASP.NET 3.5. Does anyone know what
causes this, or where I might be going wrong?
(Also posted on StackOverflow, under the same subject)
Similar:
- Datalist control in asp.net in my web application, I am using datalist, in that i am displaying images and below that i am displaying name of that image. I...
- Linkbutton’s OnClientclick Call javascript binding its parameter by Eval Hi friends, I m stuck with this problem i have a datalist which binds a list of data from database. I have taken a linkbutton...
- User Control link button click event not firing on first try Here is what i am trying to do I have a multiview and two views in it so based on click event the link the...
- Linkbutton inop when gridview placed in an update panel I have a linkbutton in a gridview that opens a Telerik report. When I place the gridview in a control panel the report won't open....
- Click Event not firing on dynamically created LinkButton I am adding numerical page links for paging of a repeater. I have used on of the numerical paging samples as my base. It works fine...
[...] On-Click Event fires first time, but not subsequent times | The … [...]
[...] On-Click Event fires first time, but not subsequent times | The … [...]
[...] On-Click Event fires first time, but not subse… [...]
[...] On-Click Event fires first time, but not subsequent times | The Largest Forum Archive [...]
[...] On-Click Event fires first time, but not subsequent times | The … [...]
[...] On-Click Event fires first time, but not subsequent times | The … [...]
[...] On-Click Event fires first time, but not subsequent times | The … [...]
[...] On-Click Event fires first time, but not subsequent times | The … [...]
[...] On-Click Event fires first time, but not subsequent times | The … [...]
[...] On-Click Event fires first time, but not subsequent times | The … [...]
[...] On-Click Event fires first time, but not subsequent times | The … [...]
[...] On-Click Event fires first time, but not subsequent times | The … [...]
[...] On-Click Event fires first time, but not subsequent times | The … [...]
Almost everyone that earnsmoney on the internet (even the millionaires) do so through affiliate marketing. Being successful in affiliate marketing involves applying the formula that makes other affiliate marketers successful. For example, autoblogging. Autoblogging has been one of the least well-known forms of making money online for quite some time… particularly because it’s quite difficult to make a good auto-blog. Yet, when done right, it can provide you with a lifetime of passive income with the only real work required being the setting up process. Video Marketing, and several other marketing strategies are all designed to drive traffic to your site, can be incorporated gradually in order to raise the position your site appears in the SERPs when any one searches for a term related to your site. And yet, even this can be totally automated.
[...] On-Click Event fires first time, but not subsequent times | The … [...]