473,405 Members | 2,373 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,405 software developers and data experts.

EditItemTemplate not showing on first click

Using a datalist, I have an ItemTemplate and an EditItemTemplate.

The default view shows several records within the ItemTemplate based on
a basic SELECT statement. When the user presses the Edit button on an
item, then they should be taken to the EditItemTemplate.

When the Edit button is pressed, it calls on a different SQL statement
to only show populate the datalist with only the record the chose. This
works fine when they click the top item, but if they click on any item
below that, only one record is shown, which is as intended, but its
still in its ItemTemplate view, not the EditItemTemplate view. When I
click the update again on the record that is showing, it then goes to
its EditItemTemplate view. Although this is functional, its not doing as
its intended and is, at least, somewhat annoying.

Here my code (the parts I think would be relevant).

This is called when the page is loaded and whenever a button is pressed.
But, when the Edit button is pressed, a slightly different SQL statement
is used instead of the one in this Sub Procedure.

Sub PopulateList(ByVal sql As String)
Dim strSQLRead As String
strSQLRead = "SELECT ID, empname, supervisor, location,
roomarea, department, " & _
"request, dtrequest, dtsupapprove, supnote,
assignto, assigndenynote, " & _
"dtassign, priority, prioritycolor, adassignby,
prioritynumber " & _
"FROM TWorkRequest WHERE approvedeny=1 ORDER BY
prioritynumber, dtassign"

If sql = "" Then sql = strSQLRead

Dim DS As DataSet
Dim objConnection As SqlConnection
Dim objDataAdapter As SqlDataAdapter

objConnection = New
SqlConnection(ConfigurationManager.AppSettings("ma intenance"))
objDataAdapter = New SqlDataAdapter(sql, objConnection)
DS = New DataSet
objDataAdapter.Fill(DS, "TWorkRequest")
dlRequests.DataSource = DS.Tables("TWorkRequest").DefaultView
dlRequests.DataBind()

End Sub

This is the sub that is called when the press the edit button. As you
can see, the SQL statement is only doing a SELECT where the ID of the
datarow from the database = the record they click on.

Sub EditRequest(ByVal sender As Object, ByVal e As
DataListCommandEventArgs)

Dim TKEY As String = dlRequests.DataKeys(e.Item.ItemIndex)

Dim strSQLRead As String

strSQLRead = "SELECT ID, empname, supervisor, location,
roomarea, department, " & _
"request, dtrequest, dtsupapprove, supnote, assignto,
assigndenynote, " & _
"dtassign, priority, prioritycolor, adassignby, prioritynumber
" & _
"FROM TWorkRequest WHERE ID =" & TKEY

dlRequests.EditItemIndex = CInt(e.Item.ItemIndex)

PopulateList(strSQLRead)

End Sub
Oct 11 '06 #1
0 1813

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

Similar topics

5
by: Gene McCrory | last post by:
Is it possible to have a CustomValidator against two controls in an EditItemTemplate on a DataGrid? Case: Have a business rule that states if ATextBox starts with "ACertainValue" then BTextBox...
1
by: Dan Sikorsky | last post by:
My ASP.Net 2.0 FormView has an EditItemTemplate, an InsertItemTemplate and an ItemTemple. When the page first loads, the ItemTemplate shows with an Edit button. If the user clicks the Edit button,...
2
by: Dan Sikorsky | last post by:
How can we tell if the value in a FormView EditItemTemplate TextBox has changed from its initial value so that we know if we have to update the corresponding db table column value? -- Thank you...
0
by: Jim in Arizona | last post by:
I've got a datalist with an ItemTemplate and EditItemTemplate. Its strange (to me), but when I have some records showing (data list items, if you will), and I click the Edit button on the first...
0
by: den 2005 | last post by:
Hi everybody, I created a Gridview with a TemplateField and there is Label control in ItemTemplate and a DropdownList control in EditItemTemplate, I was to displayed them ok when I click the...
2
by: srini.venkatesan | last post by:
I am trying to access a control from edititemtemplate in itemdatabound event, but I get a run time null reference exception. Class file : In Datagrid_update I am able to access with no issues....
2
by: Steve Hershoff | last post by:
Hi everyone, I have a DataGrid with several TemplateColumns. One of these columns has an EditItemTemplate that contains an ASP.Net DropDownList. I'm catching this DropDownList's...
0
by: dch | last post by:
I have a GridView, and when I click Edit, it is firing the OnRowEditing event ,and I am setting the edititem index, but it keeps displaying the ItemTemplate fields instead of the EditItemTemplate. I...
2
by: DC | last post by:
Hi, I am using a GridView to present data in a DataTable, which I store only in ViewState and when the user hits the "OK" button the rows in the DataTable will be used to execute transactions. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...
0
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...

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.