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


Similar Messages:

Forms Data Controls :: Gridview Checkbox Not Updating?

Dec 14, 2010

i am trying to update my checkbox column in a gridview which i cont

I can able to get the data 1 or 0 in database and able to update the checkbox as checked or unchecked

my code is

<asp:TemplateField HeaderText="Available" SortExpression="Available">
<EditItemTemplate>
<asp:CheckBox Checked='<%# ConvertToBool(Eval("Available")) %>' Runat="Server" />
</EditItemTemplate>
<ItemTemplate>
<asp:CheckBox Checked='<%# ConvertToBool(Eval("Available")) %>' Runat="Server" />
</ItemTemplate>
</asp:TemplateField>

View 9 Replies

Forms Data Controls :: AutoPostback Checkbox For Quickly Updating A Boolean Column In GridView

Jan 24, 2011

In trying to improve 'user experience' with a GridView, I have an administrative application where a GridView is displaying records from a SQL table. One of the columns is a bit column, and is displayed as a checkbox in the GridView. I want the user to be able to simply check or uncheck the box while viewing the GridView, and the value in that column for that record is immediately updated. So I set AutoPostBack="true" on the CheckBox in the GridView's Template Field.

But tests are indicating that the column value is not actually getting changed, even though the page appears to post back and displays the newly checked (or unchecked) checkbox correctly. But if I check the SQL table directly the column's value has not changed.

View 5 Replies

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 :: 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 :: Checkbox Field In GridView Is Doubled?

Mar 25, 2010

I have a table "yyy" in my database with one boolean attribute. I made entity data model and then added a gridview and objectdatasource to my page. I configured select, update, delete methods there. No problems with select. Works fine. Problem comes with updating.

View 3 Replies

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

Forms Data Controls :: Removing GridView Row If Checkbox In Template Field Is Checked...

Jun 11, 2010

I'm trying to remove a GridView Row if the user has checked a checkbox in that

[Code]....

row (the checkbox is in a template field), but I'm unable to actually remove that row from the GridView. Here's what I have, I think I'm getting the row index incorrectly...

View 5 Replies

Forms Data Controls :: Getting Data Out Of GridView Where Checkbox Template Field Is Selected?

Jun 10, 2010

I just wrote something small up with a GridView databound to the products table of the northwind database to play around with the control. I added a template field and put a checkbox in it, ProductID, ProductName, and UnitCost. I can successfully loop through the GridView and find the rows that have the checkbox checked, and can get ProductName for each row, but keep erroring out on ProductID and UnitCost. It's probably something small, but I just cannot figure it out.Here is what I have so far:

[Code]....

My code behind, where I handle a button click event to get all values in rows w/ selected checkboxes:

[Code]....

Can I not use row.Cells[i]? The only thing Intellisense gives me that makes any sense is 'rows.Cells[i].Text'... not sure what else to do.

View 6 Replies

Forms Data Controls :: Databound Checkbox Default Check Not Working?

Oct 6, 2010

I have a datagrid which is bound to a stored procedure in the code behind. This works fine. But the datagrid contains a checkbox which I need to be default checked. First I didn't bind the checkbox and just used:

<ItemTemplate> <asp:CheckBox ID="chkSelection" Runat="server" Checked= "true" /> </ItemTemplate>

but they show as unchecked. then bound it using:

<ItemTemplate>

View 4 Replies

Forms Data Controls :: Calculate SUM Of Gridview Column Where Template Field Checkbox Is Ticked On Button Click

Nov 9, 2010

I have 5 gridviews, all of of them have a Checkbox template field. I already did SUM of a specific column in the gridviews and displayed the Total in the gridview footers.

There is a submit button on the page as well.(this is not in a template column in the gridview)

what i do is select some rows in the gridviews by ticking the checkbox. Then I click on the submit button and the values change in the database and page refreshes with the new Total in the gridview footers. Any row that was ticked. the checkbox for that row in the gridview gets disabled. so cannot change the value again.

Now i want a way to show a popup with a SUM of those rows that are ticked recently and the SUM of already ticked and disabled rows before the values change for the ticked rows in the gridview when the submit button is clicked.

View 8 Replies

Forms Data Controls :: How To Display A Checked Checkbox When Field Value=1 And Unchecked When Field Value=0

Apr 22, 2010

I am using a GridView Control to display multiple fileds with 0's and 1's.

I am using template fields where CheckBoxes are used.

Where exactly and how do I apply the Logic to get a checked CheckBox when field Value=1 and unchecked CheckBox when field Value=2 .Also some times to be able to write a YES where fieldValue=1 or NO where filedValue=0

Do I apply this logic using asp or C#? How?

View 2 Replies

Forms Data Controls :: Change The Databound Field On A Grid?

Mar 6, 2011

I have to modify a page so that depending on who views the page i will show client or client Type, its easy enough to change the text but I cant see how to change the datafield

View 1 Replies

Forms Data Controls :: Add 12 Months To Databound Date Field?

Mar 14, 2011

I have an "effectivedate" field that is displayed using a label inside a detailsview control... In the code behind I need to add 12 months to this to check if a policy is up for renewal or not...

To find the control I use this code... Dim EffectiveDate As Label = DetailsView1.FindControl("EffectiveDatelbl").ToString
But when I try and convert the label to datetime type using this... Dim ExpireDate As DateTime = EffectiveDate.AddMonths(12)

I get the error - Cannot convert string to date, addmonths is not a member of label etc...

View 4 Replies

Forms Data Controls :: Databound Checkbox List, Default Values And SelectedIndexChanged Event

Jul 12, 2010

i have a check box list control that is used for showing related files to some post.

what i want to do is set the databound items "checked" to true by default

then,

if a user unchecks some item and clicks the save button. then the selectedindexchanged will fire and i will do some logic.

what i have done is.

--Set All Databound items to "checked" --

[code]....

in the end i want the item that was unchecked to be removed (all other items will remain checked). but even before that, when the user control is loaded all the files that were bounded are being deleted by the index change event.

View 3 Replies

Forms Data Controls :: Adding A Calculated Field To A Databound Control?

Oct 19, 2010

I'm using a gridview to extract a set of records. I need to add another field to the gridview, which can calculate the difference between a date associated with each record and the current date.

View 6 Replies

Forms Data Controls :: Updating Checkbox In DataGrid?

Jan 22, 2010

I have checkbox in datagrid. I m getting the right data from database. As my database is oracle, I m unable to boolean. so, I m using char value to store checkbox value.I m getting the right checkbox value but when I m trying to update checkbox, its just post back but it is not storing correct value.

View 1 Replies

How To Add A Non-databound Checkbox To A Gridview

Sep 2, 2010

1) For some reason the MainDivision column in this is displaying bold and centered (the rest are left and not bold). Anybody see something that creeped into this markup that might be causing this?

HTML Code:

[code]....

2) How can I add a non-databound checkbox to a gridview? It only seems to appear if I bind it to something, but I want it so the user can check which rows he wants to perform an action against, so it has no value other than UI interaction.

View 3 Replies

Forms Data Controls :: Updating Checkbox Value Through ObjectDataSource Update Method

Jan 4, 2011

I am very new to updating the datasource using ObjectDatasource. I have a checkbox on click of update the update method triggers but though teh check box is checked, the value is updated as false.

<asp:TemplateField HeaderText="IsPrimary" SortExpression="IsPrimary">
<EditItemTemplate>
<asp:CheckBox runat="server" ID="chkIsPrimary" Checked='<%# Eval("IsPrimary") %>' />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Remarks">
<EditItemTemplate>
<asp:TextBox ID="txtRemarks" runat="server" SkinID="longTextBox" TextMode="multiLine"
Text='<%# Bind("Remarks") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>......................

View 2 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

Web Forms :: Updating Just One Field In The Gridview Update?

Aug 9, 2010

I was wondering if when you add the update link for gridview records, is there a way to only allow the user to update just one field in the record?

View 1 Replies

Web Forms :: Updating Text Field Rather Than Gridview?

Feb 26, 2011

I was able to get the code below to give me the value I want from my SQL table however it has to display it in a gridview so I assume that something in the code acutally makes the result a data source rather than a string value.

[Code]....

View 9 Replies

Forms Data Controls :: Select All CheckBox In Gridview When Click To Header CheckBox?

Aug 20, 2010

I want to select all checkBox in Gridview when click to header checkBox.I have created design such that CheckBox is not available to header of Gridview.It is in other table. Below is design of gridview.

[Code]....

View 9 Replies







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