Hello All,
I am having trouble while updating the detailsview. The onItemcommand executes twice.
Could anyone please help .
It is driving me insane
Thanks,
Teju
7 7400
Please provide more information. Thanks.
Hello ,
I am using details view prgrammatically using code behind to poulate and perform other operations on detailsview.
for editing data i am using modechanging event and while clicking on the update button i am calling onitemcommand.
When i click the update button it call onitemcommand and checks for command name=Update
then i retrieve the text box values which are changed in the edit mode and try to print it just for testing whether it gets corrects values, I realised that it is printing twice, so i think some how it is executing twice as no where other than that iam using response.write
I hope iam making sense, if not i will post my code on monday.
Thanks for helping.
You may be having a postback problem. Using page.ispostback sometimes resolves this type of issue. HTH.
Hello,
Thanks, for your concerned reply, it does seems to sort out the problem.
But when i click on save button or the update button, it should get back to read mode. I do use chage mode even t once the details are updated.
It pops up with error details view cannot change mode while it is updating . I am posting my code behind on VB file for your reference. -
- //Onclick button call the grid view which is populated using sql datsource
-
Protected Sub btsearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btsearch.Click
-
Dim search = txtsearch.Text
-
Dim quervar = Request.QueryString("search")
-
Response.Write("loop for button clicked<br>")
-
End Sub
- //Called when linkbutton button is clicked on the gridview to display the details
-
-
Sub populatedetails(ByVal search, ByVal quervar)
-
Dim myCommand As New SqlCommand("sp_XXX", MyConnection)
-
myCommand.CommandType = Data.CommandType.StoredProcedure
-
myCommand.Parameters.Add(New SqlParameter("@strModule", SqlDbType.NVarChar, 1000)).Value = search
-
Response.Write("loop for populate")
-
Dim myAdapter As New SqlDataAdapter(myCommand)
-
myCommand.Connection.Open()
-
myCommand.ExecuteNonQuery()
-
-
Dim DS As New DataSet
-
myAdapter.Fill(DS)
-
-
DetailsView1.DataSource = DS
-
DetailsView1.DataBind()
-
myCommand.Connection.Close()
-
-
End Sub
- //OnItemCommand
-
Protected Sub ChangeDetails(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewCommandEventArgs) Handles DetailsView1.ItemCommand
-
-
If (e.CommandName.Equals("Update")) Then
-
//Calls function for update
-
UpdateDetailsView()
-
End If
-
-
-
-
End Sub
- //Update Function
-
//HOW DO I CHANGE THE DETAILS VIEW TO READ MODE AFTER UPDATE
-
Sub UpdateDetailsView()
-
Dim supId As HttpCookie
-
supId = Request.Cookies("SSMCODE")
-
Dim sup = supId.Value
-
-
If Not (IsPostBack) Then
-
Response.Write("hello")
-
-
-
End If
-
-
End Sub
-
-
-
Sub CustomerDetailsView_ModeChanging(ByVal sender As Object, ByVal e As DetailsViewModeEventArgs)
-
Response.Write("loopfor modechanged<br>")
-
Dim supId As HttpCookie
-
supId = Request.Cookies("SSMCODE")
-
Dim sup = supId.Value
-
Dim search = txtsearch.Text
-
Dim quervar = Request.QueryString("search")
-
DetailsView1.ChangeMode(e.NewMode)
-
If e.NewMode = DetailsViewMode.Edit Then
-
DetailsView1.AllowPaging = False
-
End If
-
populatedetails(sup, quervar)
-
End Sub
-
-
Sub chkcancel(ByVal sender As Object, ByVal e As DetailsViewInsertEventArgs)
-
e.Cancel = True
-
End Sub
-
- //called ondatabound
-
Sub popdrp(ByVal sender As Object, ByVal e As EventArgs)
-
Dim supId As HttpCookie
-
supId = Request.Cookies("SSMCODE")
-
Dim sup = supId.Value
-
-
If DetailsView1.CurrentMode = DetailsViewMode.Edit Then
-
Response.Write("loop for edit databound<br>")
-
-
Dim drp2 As DropDownList = CType(Me.DetailsView1.FindControl("drporganiser2"), DropDownList)
-
Dim drp3 As DropDownList = CType(Me.DetailsView1.FindControl("DropDownList1"), DropDownList)
-
Dim str = "SELECT distinct ssm_organisers.Organiser_Name,ssms.Organiser2_Code FROM ssm_organisers INNER JOIN ssms ON ssm_organisers.idStaff = ssms.Organiser2_Code where ssms.SSM_Code='" & sup & "' order by ssm_organisers.Organiser_Name asc"
-
Dim myCommand2 As New SqlCommand(str, MyConnection)
-
-
-
Dim DR As SqlDataReader = myCommand2.ExecuteReader()
-
If DR.HasRows Then
-
DR.Read()
-
-
Dim objvalue = DR.GetValue(0)
-
-
If objvalue = "" Then
-
-
Response.Write(objvalue)
-
drp3.Visible = True
-
drp2.Visible = False
-
drp2.Enabled = False
-
-
-
Else
-
-
drp2.Visible = True
-
drp3.Visible = False
-
-
-
End If
-
End If
-
-
End If
-
-
-
-
-
-
-
-
End Sub
-
- //Called From Grid VIEW
-
Public Sub LinkButton_Command(ByVal sender As Object, ByVal e As CommandEventArgs)
-
-
Dim quervar = Request.QueryString("search")
-
er = e.CommandArgument
-
Response.Cookies("SSMCODE").Value = er
-
-
populatedetails(er, quervar)
-
End Sub
-
-
-
-
-
-
-
-
I hope this explains my problem. After hunting so many things now IAm totally confused.
MANY THANKS FOR YOUR HELP
Hello,
Please, if anyone could help me out.
Many Thanks,
Teju
This isn't your code is it? You need to engage in some debugging. HTH.
This isn't your code is it? You need to engage in some debugging. HTH.
I didn't get you when you said this isn't your code. My question is how do i change the mode in detailsview after clicking update button to readonly back
I tried databind method, disabling view state but none of them works.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Pete |
last post by:
One way to accomplish thumbnail imaging without excessive lines of
code is using the web browswer control (see WebBrowseWeb form in
Solutions.mdb). The trouble is when I point to a directory path...
|
by: Nanda |
last post by:
hi,
i have an editable datagrid. how can i update the
database, When the user completes entering data for a row.
i.e., data should be updated whenever user completes
entering a row.
Thanks in...
|
by: willow1480 |
last post by:
I am developing a small little Service Control Application. I am
using a listview control with checkboxes and getting the list of
services I want to control from a text file. When you check a...
|
by: MikeY |
last post by:
Hi Everyone,
I'm having problems with my syntax on the updating part for the
Northwind.MDB. All other code seems fine. It has to do with the Order
Details on the thisAdapter.Update( ). Or I...
|
by: MikeY |
last post by:
Hi Everyone, (Just doing a repost case my previous post was too far down the
line, sorry fro the repost)
I'm having problems with my syntax on the updating part for the
Northwind.MDB. All other...
|
by: John Morgan |
last post by:
I have my first small SQl Server 2005 database developed on my local
server and I have also its equivalent as an online database.
I wish to update the local database (using and asp.net interface)...
|
by: Rich Raffenetti |
last post by:
In the listview control I can set the highlighted item with
listview.focus()
listview.items(integerValue).selected=true
How do I programmatically scroll the pane of the details view to bring...
|
by: randy.buchholz |
last post by:
Been fighting this one for a while, looking for help.
I have a simple page with a grid view and details view (just managing a
single table). The details view is primarily used for creating new...
|
by: Mike |
last post by:
So here's the situation (.NET 2.0 btw):
I have a form, and on this form is a textbox among many other
databound controls. The textbox is bound to a field in a data table
via the Text property. ...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
| |