.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

problem when programmatically updating value

Posted By:      Posted Date: October 11, 2010    Points: 0   Category :ASP.Net

Using vb.net/asp.net 2005 & Sql Server 2005.

I have a gridview that is using a sqlDataSource to update the value and when I trace through the following code, get the EmailID and query the database table to see if the change is made when inside this function the actual value of the emailAddress is changed:

    Protected Sub grdvMyGridView_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles grdvMyGridView.RowCommand

            Dim intRow As Integer = CInt(e.CommandArgument)
            Dim row As GridViewRow = grdvMyGridView.Rows(intRow)

	If e.CommandName = "Update" Then

                Dim emlID As String = grdvMyGridView.DataKeys(row.RowIndex).Value.ToString
                Dim emlAddr As String = CType(row.Cells(0).Controls(0), TextBox).Text

                SqlDataSource1.UpdateParameters("EmailID").DefaultValue = CInt(emlID)
                SqlDataSource1.UpdateParameters("EmailAddress").DefaultValue = emlAddr

                grdvMyGridView.DataSourceID = "SqlDataSource1"

            End If

        Catch ex As Exception
		Throw ex
        End Try

    End Sub

I have a breakpoint at the rowCommand function shown abo

View Complete Post

More Related Resource Links

problem on Page_PreRender with RangeValidator control and programmatically setting Maximum and Minim

I am new to the ASP.NET /C# dev. I run into a weird bug when using the RangeValidator Control inside a Formview. I have my DateTime field with validator and it work fine until I submit the page, it actually insert the row into the database but then when the page reload I get the following exception.Server Error in '/Budget' Application. The value '' of the MaximumValue property of 'RV_AjoutUtilisateurDate' cannot be converted to type 'Date'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: The value '' of the MaximumValue property of 'RV_AjoutUtilisateurDate' cannot be converted to type 'Date'. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [HttpException (0x80004005): The value '' of the MaximumValue property of 'RV_AjoutUtilisateurDate' cannot be converted to type 'Date'.] System.Web.UI.WebControls.RangeValidator.ValidateValues() +1077011 System.Web.UI.WebControls.RangeValidator.ControlPropertiesValid() +12

Problem updating records with LINQ, Concurrency?

 My project includes a grid view with some updtable fields, some fields throw an error on update and some do not and it does not really make sense. WORK_STATION_ID does not cause an error, ROOM _ID cause an error, both are int? (I am using c#) and for update I use the code liste below.using (DataClassesDataContext db = new DataClassesDataContext()) { var product = (from p in db.ASSETs where p.ASSET_ID == ASSET_ID select p).Single(); product.WORK_STATION_ID=WORK_STATION_ID; product.ROOM_ID=ROOM_ID; db.SubmitChanges(); }    Row not found or changed. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.Linq.ChangeConflictException: Row not found or changed. Source Error: Line 93: Line 94: Line 95: db.SubmitChanges(); Line 96: Line 97: Source File: C:\Projects\TEST_II\trunk\ObjectDataSourceLibrary\AssetController.cs Line: 95 Stack Trace: [ChangeConflictException: Row not found or changed.] System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode) +963417 Syst

notification email not sent when updating a task programmatically

I have a task that's in the task list and has no value in the Assigned To field. When I update the field like this: listItem[SPBuiltInFieldId.AssignedTo] = SPContext.Current.Web.CurrentUser.ID; ListItem.Update(); The task is updated (the assigned to has filled in). But no notification has been send to the person in the assigned to. But when I change the assigned to manualy to another person, and then again to the person it was before, the notification is send. So the email works and the notifications are activated, why is there no notification sent when I change the assigned to programmatically?

is there any problem if i create a site collection through programmatically which web application ha

hi all, My web application have 2  types of authentication -- for internal users (windows authentication) and external users (Form based authentication). I am creating site collections through programmatically in the web application. so this site collection should have the permission as form based authentication for external users and windows authentication for internal users. is it possible are not? please give me some suggestions on creating site collections which have form based authentication and windows authentication. thanks in advance......

Problem updating a boolean field

I have a button in a listview that updates a boolean field for the selected record. The button calls a method (ObsoleteOffice) in my BLL that sets the field (IsObsolete) to true...please see below for the code. However, the IsObsolete field never gets updated, nor does it throw an error.  In addition, the method works with string fields just fine, but nothing happens with the boolean field.  I would be grateful if anyone could shed some light on what I am doing wrong. Thanks.   //Method: ObsoleteOffice [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)] public bool ObsoleteOffice(int officeID, bool isObsolete) { offices.OfficesDataTable offices1 = Adapter.GetByOfficeID(officeID); if (offices1.Count == 0) // no matching record found, return false return false; offices.OfficesRow office = offices1[0]; // office.DateModified = DateTime.Now; office.IsObsolete = true; //Update the office record int rowsAffected = Adapter.Update(office); //Return true if exactly one row was updated, otherwise false return rowsAffected == 1; }  

Problem with updating assembly references in IIS server

I have a website which is in a Projects directory. The IIS server is set up to point to that website (i.e. any changes in the /Projects version are visible in the wwwroot version), so I can run the website locally on IIS server.One of the libararies that there is an assembly reference to in the website has been updated. If I run the /Projects website using the local ASP development server (localhost), I can open up the files in the library that have been changed and put a breakpoint in them, which will be triggered whenever that section of code is executed.However, when I run the IIS server version in webroot, if I put breakpoints in the same files, the breakpoint icons disappear, and it says that the symbols have not been loaded for the current page (presumably because the file is new, but the old code is being compiled in the assembly?). I have checked, and the library reference is set to auto update, and has the correct path to the dll in the project's .refresh file.I'm confused about this, since I thought the IIS server version was pointing to the same website as the one in /Projects, which works. If anybody has any advice on things that I can check or how I can fix this, I'd be grateful.

GridView updating problem


Hi all,

I'm trying to edit fields in my gridview, but for some reason it's not working. I've tested the sproc, and there's no apparent reason why it shouldn't work. When debugging the app and looking at e.Command.Parameters in both Updating and Updated (SqlDataSource), it only shows me the old values, which, to me, implies that this is the problem - it's not sending the updated values.

Anyone know how to fix this?

Cheers! :)

<asp:GridView ID="gvDisplayGroup" runat="server" AutoGenerateColumns="False" 
        <asp:BoundField DataField="RoleId" HeaderText="RoleId" 
            SortExpression="RoleId" ReadOnly="true" />
        <asp:BoundField DataField="RoleName" HeaderText="RoleName" 
            SortExpression="RoleName" />
        <asp:BoundField DataField="Description" HeaderText="Description" 
            SortExpression="Description" />
        <asp:BoundField DataField="role_level" HeaderText="role_level" 

Problem with assembly reference not updating


I have a solution A which references an assembly in solution B. I added the reference to the project in A by right clicking on the project > add reference, and finding the dll in the bin/Debug folder of the project in solution B in the Browse tab.
However, the reference to assembly B is not being updated in solution when I update the code in project B, even though I am making sure that I recompile the code in project B and then in project A. This means I am unable to debug A properly because the source code does not match the executable (I've checked and the location of the file the breakpoint is added to is correct).
I can go into the bin/Debug folder in project B, the date modified fields for the dll and .pdb files in

updating problem with ObjectDataSource control


hi all, i got confused about updating method with ObjectDataSource control. Those parameters just a nightmare for me. I tried use those parameters implicitly and explicitly, but coudln't get it working.

The task is to update the data from txtIllness and txtDiagnosis according to selected consultationID.

Any helps are greatly apperciated.

Thank you

Here is the code

public class ShowConsultation
    private readonly string constring;
    string name = HttpContext.Current.User.Identity.Name;
    public ShowConsultation()
        constring = WebConfigurationManager.ConnectionStrings["SurgeryConnectionString"].ConnectionString;
    public SqlDataReader GetConsultation()

        SqlConnection con = new SqlConnection(constring);
        SqlCommand cmd=new SqlCommand();
        cmd.CommandText = "SELECT Consultation.consultationID,Consultation.Illness,Consultation.Diagnosis,Consultation.Date,Patient.firstName,Patient.lastName,Patient.DOB,Patient.suburb,Patient.postCode FROM Consultation,Practitioner,Patient WHERE Practitioner.UserName=@UserName AND Practitioner.GPNo=Consultation.GPNo AND Patient.patientID=Consultation.patientID";
        return cmd.ExecuteReader(Com

Problem updating a managed metadata column value



I have a document library where I've added a managed metadata column that contains a list of city names.
So far so good, I can add documents and set a value for this column.

The problem starts when modifying a city name. E.g. I change New York into Washington.
All items that were linked to New York will still show New York and not Washington.
When adding a new document I can pick Washington from the list of cities, but in my view it will still show New York (even though I picked Washington and there is no sign of New York in the values). When opening "view properties" it will still show New York. When opening "edit properties" it will show Washington.

This is very confusing to users (and also for me)!
Is there a timer job or something that should run before all items will use the correct updated value ?

Workflow. Copy item to new list - problem updating additional fields in the new list record




I'm having a couple of problems


I have a list, List A. On a couple of triggers I want list A to copy fields to a new record in List B.

Many of the columns are the same Say, column1, column 2, colmn 3. The Copy Item is working fine.


I then want to amend several fields in the new record in List B to reflect the new info from list A, and create info in a fields (say ListBcolum4 type choice and ListBcolum5 single line).

For the life of me I cant get this to work... ive tried updating fields, creating items...

A pointer on how to do this would be greatfully received.

Problem with gridview manual updating


 I have a gridview that is connected to a SQL db. I am handling the update manually in the GridView1_RowUpdating event where I pull data out of the edited row the make calls to classes that update the DB. I am not using the built in updatecommand of the grdiview because I am doing some complex and multiple table updates.

The issue is that after I run all the code the gridview never comes out of edit mode so my page just hangs.

Any help would be appreciated.


Problem With space When updating password of active directory users from asp.net


Hello Friend's

From long time i am facing problem with Reseting password of users of active directory from asp.net.

The coding is work fine when there are no space in username but it's cause a problem when there are space in username.


usernametochange = "Ketan Patel";
                       ds.Filter = "(&(objectClass=user)(sAMAccountName=(" + usernametochange + ")))";
                       ds.PageSize = 100;

                       SearchResult account = ds.FindOne();
                       DirectoryEntry user = account.GetDirectoryEntry();
                       object[] oPassword = new object[] { "krtya#123" };

                           object ret = user.Invoke("SetPassword", oPassword);

if you have any idea about it please help me.

Thank you.....

Problem to group radio button across gridview rows

In general no one can easily group or make a single selection from radio button list inside gridview rows. There are a lot of way to make a single or unique selection from list. Here i want to share how i can address this problem in the most easiest way. Googling the problem most of the cases i saw the grouping in horizontal way. Thats why i tried to group the radio buttons in vertical manner. Let i have a requirement like below:

Export SharePoint List to Excel Spreadsheet Programmatically using C#

In SharePoint applications, Custom Lists are used to store business data and Document Libraries to store the documents. But for data manupulation and analysis, Microsoft Excel provides very rich features as compared to SharePoint Lists. That's why people still loves to work on Microsoft Excel Sheets.

Creating an Excel Spreadsheet programmatically using VB.NET

The Interoperability services make it very easy to work with COM Capable Applications such as Word and Excel. This article reveals using Excel from a managed application. Excel is the spreadsheet component of Microsoft Office 2000. The majority of Excel programmatic functionality is exposed through Automation via the type library Excel9.olb. The intention of this article is to express that a managed application can interrelate with Excel as a COM server.

Creating an Excel Spreadsheet and Adding Data to It Programmatically

The Interoperability services make it veryeasy to work with COM Capable Applications such as Word and Excel. Thisarticle reveals using Excel from a managed application. Excel is thespreadsheet component of Microsoft Office 2000. The majority of Excelprogrammatic functionality is exposed through Automation via the typelibrary Excel9.olb. The intention of this article is to express that amanaged application can interrelate with Excel as a COM server.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend