Forms Data Controls :: Gridview Copying Data From One Field To Another When Updating

Mar 5, 2010

I have a gridview based on a sqldatasource that has some colums from which two colums showing the data of two fields: field1 and field2. field1 is an ID which should not be updated and therefore it is readonly=true. The sql-query from the sqldatasource is:

SelectCommand="SELECT field1, field2 from anyView"

What I want is, that when a row is updated, then the value from field1 should be copied to field2 The update-query is:

UpdateCommand="UPDATE myTable SET field2=@field2 WHERE field1=@field1"

My idea was, that the @field2 paramter gets the value from the query string out of field1:

<UpdateParameters>
<asp:QueryStringParameter Name="field2" QueryStringField="field1" Type="Int32" />
</UpdateParameters>

But this does not work. Is there an easy way to copy the data from field1 to field2 when updating the row? In addition, is this possible, even if field2 ist not shown in the gridview (i.e. field2 is selected in the query but is not a field in the gridview but should be updated with value of field1).

View 3 Replies


Similar Messages:

Forms Data Controls :: Gridview Update From Template Field Not Updating

Feb 3, 2011

I have a gridview where I am using the update. I have converted the label into a templatefield and added a dropdownlist which is getting polulated in the Rowdatabound event. When I test the update i get an error

Cannot insert the value NULL into column 'StartTime', table 'HTC.dbo.EventDates'; column does not allow nulls. UPDATE fails.The statement has been terminated. so I am ussuming its still trying to update from the label rather than using the dropdownlist. here is my code:

[Code]....

View 1 Replies

Forms Data Controls :: Updating Field Value In Gridview Rowupdating Event

Mar 15, 2010

I have a Modified Date and Modified By column in my gridview and I want them to be updated with the current date and current user any time a user updates the row.

I converted my columns to template fields and the textboxes in the edititemtemplate are bound to my sql data columns "ModifiedDate" and "ModifiedBy"

Then I added the attached code in my RowUpdating event.

When I test the code and click the Update link on my gridview I don't get an error but the values don't update either. I put a breakpoint on the code and when I hover over "ModifiedDateLabel.Text" I see the old value of the field so I know I'm accessing the control correctly.

View 3 Replies

Forms Data Controls :: DataBound GridView Checkbox Field Not Updating SQL?

Jan 14, 2011

So I am uding a GridView bound to a SQL data source.

I have a template feild bound to a SQL BIT

<EditItemTemplate <asp:CheckBox ID="chkSelected" runat="server" Checked='<%# Bind("Selected") %>

The original Item Template was Enabled ="false" I changed this so that you did not have to set the row to a state of edit in order to just select a row. I enabled it so that you could "select" any row with out putting it in a state of edit. the only value changing is if its selected or not. What i am trying to do is use the Data Source Update method to update the bit in the database based on the check box. Currently Update() returns 0. I believe this is because the row/feild is not marked as changed so the Data Source does not see it as something that needs to be updated.

What I am hoping for out of this is post is a way that the rows whom check value has changed to be marked as changed/edited so that the data source will update the database with the values of the check boxes. If all rows are updated this is acceptable as well. I know this is a super simple solution but i have been out of the .NET for a little bit.

View 7 Replies

Forms Data Controls :: GridView Not Updating / After Clicking Update Command Field?

Mar 12, 2011

I have a gridview and sqldatasource in a form. My sqldatasource has select,delete and update command. The delete command is working but the update doest not work when I click the update command field.

Here is my code [Code]....

View 3 Replies

Forms Data Controls :: Updating A Single Field In A Gridview Row With A Button Click

Aug 4, 2010

I created a gridview that is bound with an SQL datasource - I added a gridview button column. I need to update/insert 'Y' on a specific cell in the row when I press the button

This is my gridview code

[code]....

The button column I have says delete on it but it shouldn't really delete it - Once I press the button it puts a 'Y' on a column that is filtered out by my sql statement in the sql datasource

View 13 Replies

Forms Data Controls :: Copying Tailspin Stuff But With Gridview Controls?

Feb 7, 2011

I'm trying to setup a gridview control to have a column full with a hyperlink called "Details" that redirects to a template page that has a formview control. It's supposed to transport the productID of it's corresponding row to that other page, which already has an Entitiy DataSource setup to a database, and it's supposed to use that product ID to fill in fields on that Formview Template.

I was trying to copy this tutorial:

[URL]

but he uses a listview control instead. Reason I'm using gridview is because it's a gridview that filled on the spot after it's queried to by a search engine.

How would I accomplish somthing similar but with gridview controls instead of listview controls? What kind of syntax would I want to be looking at?

View 3 Replies

Forms Data Controls :: Formatting Updating An Edit With Template Field?

Jun 26, 2010

I'm using a formatting expression with a template field. When the details view goes into edit mode the formatting is applied. It looks great because it applies the currency formatting. It shows up as "$60,000.00" instead of "60,000.0000". But then when I do the update it gets rejected because of the $. Is there a way to keep the formatting for the user to see in edit mode but remove the $ when doing the update so I don't get the error?

The error: Exception Details: System.FormatException: Input string was not in a correct format.

template field:

[Code]....

View 5 Replies

Forms Data Controls :: Updating A Currency Field Of An Access Table Through Detailsview, Cannot Input Decimals

Oct 23, 2010

I changed a text field to a template field assigning the selected text and the selected value is being assigned to another currency field also templated. I get aa error

[FormatException: Input string was not in a correct format.]

View 10 Replies

DataSource Controls :: Updating SQL Data Fields By Field Index?

Jan 7, 2010

I have a situation where I have a file with each Account Record contains Monthly Expense Total Fields and Monthly Budget Fields for 2009, 2008 and 2007. I'm working with 72 fields (36 Expense and 36 Budget).

Need to create New Year Proceure that will shift data from 2008 to 2007, 2009 to 2008 and move Zeros to 2009 for both Expenses and Budgets.

I can do this using Parameters and Update SQL but I am under the impression that I must specificaly name each field in defining Parameters and SQL Update Command.

Since all fields are sequential withing a record, is there a way that I can use a For/Next loop to index my way through the fields moving data from one year to another?

When using DataReader I'm able to use reader.item(index) to access data record fields.

View 3 Replies

Forms Data Controls :: Disable/Invisible Field In Gridview Based On Another Field?

Jul 9, 2010

I have 2 fields in my gridview one called ScriptType the other BagNo, when a user click the edit button, I would like the BagNo filed to be disabled if the ScriptType field is = "TTA" and enabled otherwise. How can I do this?..something along these lines see below..I am using VB..

[code]...

View 14 Replies

Forms Data Controls :: Hyperlink From A Gridview Field To A Field In Another Gridview?

Jun 11, 2010

I want to hyperlink from a field in one gridview to a field in another gridview based on id. I've tried many ways but haven't seen success.

View 20 Replies

Forms Data Controls :: Simulate The Gridview Function Of Updating Row Or Cell Data

Feb 13, 2010

I have an asp.net page with a gridview control on it but I want to allow the user to also be able to update the selected row from a series of textboxes. I simply need the code for a button click event to do this.

button is called button1
textbox is called textbox1
gridview control is named gridview1
record to be modified is in 3rd column called PlayerName

The row to be edited will always be the only record shown and will always be selected by code I've already written. I will also need to know if the record must be set to edit mode to make the button click code work.

View 7 Replies

Forms Data Controls :: Updating Encrypted Data To SQLServer Database With GridView

May 31, 2010

I'm just wondering if anyone has come across a good, easy method for updating a SQL Server 2000 DB table using the edit feature in GridView. The catch here is that I need it to encrypt, send to database, then decrypt when the page calls it to be displayed. I have successfully implemented an insert method using FormView with encryption. For some reason, I just can't seem to figure out the edit/update.

View 1 Replies

Forms Data Controls :: Duplicate Data In Gridview And Updating Textbox In DetailsView

Feb 4, 2010

Duplicate Data in Gridview and Updating textbox in DetailsView

View 2 Replies

Forms Data Controls :: How To Get Data Key Of The GridView Row After Updating (in RowUpdated Method)

Jan 5, 2011

I have a requirement something as below.

1. I will click on the EDIT link in one of the grid view row. The row will change to edit mode

2. I will update the values and click update link in edit mode and edit mode closes.

3. At this point I need to capture the datakey of the updated row into some variable

View 3 Replies

Forms Data Controls :: Preserver Old Values While Updating Data Using GridView?

Dec 9, 2010

I'm using ADO.Net code to access and update the data from the database. I'm using GridView for presentation. I wish to preserve old values of all the columns while updaing the records.

I'm using Code behind and not d Data Source controls. I wish to list the old records once record is updated.

View 5 Replies

DataSource Controls :: System.Data.Datatable Updating SQL Server Image Field

Jul 1, 2010

I have a datatable for which i'm defining a dataadapter. I'm specifying an updatecommand with sqlparameters for the dataadapter I set the updatecommand's parameters using the following overload:

[Code]....

The length 16 is used because this is the length of the field according to sql (the image datafield is a pointer of size 16) I noticed .Net is actually truncating the string because of the length i'm setting. An image of size 3kb will properly upload if we set the length field to be greater than 3kb The question I have is what is the proper value (or strategy) to use in order to set for the length field so that ALL images will properly update to the database, with each using the appropriate size.

I guess i could theoretically set the length to be maxint, but this seems sloppy. Looking at sqlparameter documentation i didnt see an 'unlimited' or 'default' length i could set, which would allow each update statement called to use the appropriate size for the data length for that row.

View 1 Replies

Forms Data Controls :: Editing And Updating Data In The Gridview?

Feb 14, 2010

regarding editing and updating the data in the gridview?

View 4 Replies

Forms Data Controls :: How To Use A Field Value In Another Field In Gridview

Dec 19, 2010

I have a grid view, and I add new column as a hyper link field, I want the navigationURL for this field to be Pageexample.aspx?ID=other field value like this

[code]...

is that possible ?

View 2 Replies

Forms Data Controls :: GridView Not Updating / Created Simple Apps To Edit Data In An Access Database?

Dec 18, 2010

I have created a simple application to edit data in an access database using gridview but its not working , the results are shown correctly , but when i click update nothing happens..

Here is my code

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" EnableModelValidation="True" DataKeyNames="id" >
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="id" HeaderText="id" InsertVisible="False"
SortExpression="id" />
<asp:TemplateField HeaderText="NAME" SortExpression="NAME">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("NAME") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("NAME") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="FATHER_NAME" HeaderText="FATHER_NAME"
SortExpression="FATHER_NAME" />
<asp:BoundField DataField="MOTHER_NAME" HeaderText="MOTHER_NAME"
SortExpression="MOTHER_NAME" />
<asp:BoundField DataField="CLASS" HeaderText="CLASS" SortExpression="CLASS" />
<asp:BoundField DataField="gram" HeaderText="gram" SortExpression="gram" /
<asp:TemplateField HeaderText="Remark" SortExpression="Remark">
<EditItemTemplate>
<asp:DropDownList ID="PS" runat="server" SelectedValue='<%# Bind("Remark") %>'>
<asp:ListItem>PASS</asp:ListItem>
<asp:ListItem>FAIL</asp:ListItem>
<asp:ListItem>APPEARED</asp:ListItem>
<asp:ListItem>NOT APPEARED</asp:ListItem>
<asp:ListItem></asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Remark") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>"
ProviderName="<%$ ConnectionStrings:ConnectionString2.ProviderName %>"
UpDatecommand = "update [REGULAR] set [NAME] = ?, [FATHER_NAME]=?, [MOTHER_NAME]=?, [CLASS]=?, [gram]=?, [Remark]=? where [id] = ?"
SelectCommand="SELECT [id], [NAME], [FATHER_NAME], [MOTHER_NAME], [CLASS], [gram], [Remark] FROM [REGULAR] WHERE (([CLASS] = ?) AND ([SCHCD] = ?))">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList3" Name="class"
PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="DropDownList1" Name="schcd"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:SqlDataSource>

View 1 Replies

Forms Data Controls :: GridView And Editing Data - Check For Correct Data In Each Field

Apr 7, 2010

I have loaded up a gridview object with data. I have turned on Edit on the grid. It lets me edit the data, but I also want to put some code to check for correct data in each field. I tried to assign a requiredfieldvalitor, comparevaliditor but they don't work. Is there an event I can capture to fire up some code before the grid sves my data?

View 3 Replies

Forms Data Controls :: How To Update Parent Gridview After Updating Child Gridview

Dec 14, 2010

I have a parent gridview which has a child gridview in the itemsTemplate. Both are binded to different SqlDataSources. I can successfully update and delete rows in the child gridview. After updating in the child gridview, some related data in the parent gridview are not updated automatically. So i have placed ParentGridview.Databind() in the rowupdated event of child gridview. But it doesnt look working.

How can i accomplish this?

View 4 Replies

Forms Data Controls :: Updating GridView Based On Computation In Another GridView

Jan 27, 2010

[Code]....

[Code]....

View 1 Replies

Forms Data Controls :: Updating GridView With GridView Columns That Are Readonly

Feb 20, 2011

I have a GridView with 5 fields. Only two of the fields are edittable (the others are READONLY).

I have an UpdateCommand as follows

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:NHLPOOL %>"
SelectCommand="SELECT [PlayerID], [Firstname], [lastname], [Goals], [Assists], [Goals]+[Assists] as Points, [AsOfDate] FROM [PlayerStats], [Player] where [PlayerStats].[PlayerID] =[Player].[ID] ORDER BY Points DESC"
UpdateCommand="UPDATE PlayerStats SET Goals =@GOALS, Assists =@ASSISTS, AsofDate=GETDATE() WHERE PLAYERID = @PLAYERID">
</asp:SqlDataSource>

The issue is I want the PLAYERID GV column to be READONLY but I get a runtime error when updating if the PLAYERID is READONLY.

I get the error "

Must declare the scalar variable "@PLAYERID"."

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved