Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Controls / March 2008

Tip: Looking for answers? Try searching our database.

Updating GridView Problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve Wofford - 28 Mar 2008 04:29 GMT
I have the default "Enable Editing" check  on the GV.

When a user clicks on the "Edit" for a row, I need to have one of the
columns set to a value which is stored in a QueryString.

After the "Edit" button is clicked I can set the TextBox value as desired,
however, after clicking "Update" the changes are not posted to either the GV
nor the database.

Here is what I have currently.

<asp:TemplateField HeaderText="modifiedby" SortExpression="modifiedby">
<EditItemTemplate>
<asp:TextBox ID="tbEditItemModifiedBy" runat="server" ReadOnly="false"
Text='<%# Request.QueryString("userid").ToString()%>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="tbItemModifiedBy" runat="server" Text='<%# Bind("modifiedby")
%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>

I am able to "Edit" other values and are saved accordingly. I am having the
problem whey I try to dynamically update values on the fly.

TIA,

Steve
Stan - 28 Mar 2008 15:13 GMT
> I have the default "Enable Editing" check  on the GV.
>
[quoted text clipped - 24 lines]
>
> Steve

The key to why it doesn't work is that the "modifiedby" column of the
database is not bound to the EditItemTemplate. Note that the
ItemTemplate has the 'Bind' method in the Text property of the label.
In order for the contents of the Textbox in the EditItemTemplate to be
bound similarly, the same expression is required.

As it is, Update will not change the database "modifiedby" column
value.

In order for your Update method to work you will have apply the change
programatically during the "RowUpdating" event using a statement
something like this:

e.NewValues("modifiedby") = Request.QueryString("userid")

HTW
Steve Wofford - 29 Mar 2008 03:48 GMT
Didnt have to change a thing, just had to copy/paste.

Steve

On 28 Mar, 03:29, "Steve Wofford" <intrar...@yahoo.com> wrote:
> I have the default "Enable Editing" check on the GV.
>
[quoted text clipped - 27 lines]
>
> Steve

The key to why it doesn't work is that the "modifiedby" column of the
database is not bound to the EditItemTemplate. Note that the
ItemTemplate has the 'Bind' method in the Text property of the label.
In order for the contents of the Textbox in the EditItemTemplate to be
bound similarly, the same expression is required.

As it is, Update will not change the database "modifiedby" column
value.

In order for your Update method to work you will have apply the change
programatically during the "RowUpdating" event using a statement
something like this:

e.NewValues("modifiedby") = Request.QueryString("userid")

HTW

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.