Data Controls :: Updating GridView With Readonly DateTime Value In TemplateField

Dec 21, 2013

I am trying to update values in the GridView but have some issue with the Datetime (which I want to keep Readonly). On updating the GridView, I am getting the following error: 

ERROR: "System.FormatException: Input string was not in a correct format." 

Database COLUMN:BestillingDato, nVarchar(50), Allow Nulls

HTML Form:

<asp:TextBox ID="txtBestillingDato" runat="server" Width="260px"></asp:TextBox>

GRIDVIEW Table:

<asp:TemplateField HeaderText="Bestilling Dato">
<ItemTemplate>
<asp:Label ID="lblBestillingDato" runat="server" Text='<%# Bind("BestillingDato","{0:d}") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>

[Code] .....

View 1 Replies


Similar Messages:

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

Data Controls :: How To Format DateTime Column In GridView TemplateField

Jun 16, 2015

I am new in Asp.Net Web development..........

I want to convert datetime format as per local date time format from GMT formatted date timebinded in a gridview using Boundfield using javascript only.

View 1 Replies

Data Controls :: Format DateTime In Eval Inside TemplateField Of GridView

May 7, 2015

I have a SQL2012 database in the database in have a table with many cloumns one of the columns is date. on the gridview i am using a ItemTemplate field to display date

<asp:TemplateField HeaderText="DATE">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Date").ToString() =="2000/01/01 12:00:00 AM "? "" : Eval("Date" ,"{0:dd/MM/yyyy}").ToString() %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>

The Problem i having is that i am testing weather the date matches something and based on that it display "" else it should display the date based on the formotting but both are not working.

View 1 Replies

Forms Data Controls :: GridView BoundField Vs. TemplateField For Updating?

Feb 17, 2011

I have one two GridViews on a page. One Gridview uses BoundFields inside of the GridView and the Update statement works just fine. The other GridView utilizes TemplateFields due to the fact that Validation Expressions have to be used. I also want This GridView to be able to update the vlues when the user clicks on the Update link on the right side of the GridView. The GridView that uses the BoundFields updates just fine, but the GridView that uses TemplateFields will not update. I have checked and everything is correct other than this difference of BoundField and TemplateField.

View 2 Replies

Forms Data Controls :: GridView Not Updating / AutoGenerateColumns="false" And Have TemplateField

Mar 6, 2010

My GridView is not updating when AutoGenerateColumns="false" and have TemplateField. It works fine when I comment out the BoundField and TemplateField and change the AutoGenerateColumns to true. Am I missing something?? Below is the markup:

[Code]....

And this is my BO method for ODS:

[Code]....

View 7 Replies

C# - TemplateField Not Updating In GridView Using LINQDataSource?

Sep 2, 2010

Im using a LINQDataSource to populate a GridView of Universities.

Each University has an associated State, which is in another table and associated by a foreign key (StateID).

I have a TemplateField in the GridView so that when you view it normally it displays the StateName which comes from the State table and when you edit it shows a DDL populated with everything from the State table.

[Code]....

If I debug, inside of RowUpdating, GridViewUpdateEventArgs.NewValues doesnt even have a key for State.

Question: How do I let my gridview know I want it to update this column? All the BoundFields just seem to work...

View 1 Replies

Data Controls :: GridView BoundField Column Readonly - Disable Specific Columns In Edit Mode Of GridView

May 7, 2015

How to disable editing the data in the cells of datagridview in c#?

View 1 Replies

Forms Data Controls :: Set ReadOnly For A GridView Column In C#?

Apr 11, 2010

I need to change ReadOnly from false to true for one column in GridView depending on who the user is. In my particular case it is a BoundField (also I would like to know how to do it for a Template field as well) and DataField is "dteRequired". I would like to code something like that right in the Page_Load handler:

View 8 Replies

Forms Data Controls :: Gridview Readonly Colums?

May 4, 2010

I have a problem specific to the gridview control, i am using the datasource to generate an update method for the data in my table.

Some of my columns are display only fields so i have set them to "read only = true" Everything seems fine when the page loads but when i click update, the columns that were editable update fine but the ones set to read only have now updated the databasewith a null value. Am i missing something here?

View 5 Replies

Data Controls :: Export GridView To ReadOnly Excel File?

Sep 20, 2015

I have generated a Excel report using C#,which generated fine.now i need to do all of those field is to be noneditable.how could i do it

Here my Export to Excel COde below:

#region Export to Excel
if (dt.Rows.Count > 0)
{
string filename = reportName + ".xls";

[Code]....

View 1 Replies

Forms Data Controls :: Getting Values From Readonly Textbox In Gridview Footer Row

Sep 7, 2010

[Code]....

works if the textbox is not readonly. What do i do to get the readonly textbox value?

View 9 Replies

Forms Data Controls :: Set Readonly Attribute In Gridview Row Itemtemplate Textbox?

Mar 29, 2011

I have four Itemtemplate textbox with in my Gridview.... i want to set Readonly attribute dynamically only one itemtemplate textbox, how to do that,

I have done one for my gridview footer its working,

DirectCast(GridView1.FooterRow.Cells(2).FindControl("TxtSum"), TextBox).Attributes.Add("readonly", "readonly")

this time i'm expecting for row template textbox.

View 4 Replies

Forms Data Controls :: How To Locate The Readonly Property In A Gridview At Run Time

Feb 21, 2010

I am trying to set the readonly property for the columns of a latebound gridview.

My data source is a select SPROC which returns a lookup group of records.

The gridview control is bound when the page loads.

The gridview has an edit control and I would like to allow the editing of specific records.

I cannot find the readonly property of the row columns to set.

I tried this :

[code]...

View 2 Replies

Forms Data Controls :: How To: Get Gridview Back Into Readonly Ned From Edit Mode

Mar 31, 2010

I have some custom Code to handle the Insert And Edit Mode on the OnRowCommand="CheckTheData" property of the GridViewThe Grid Starts in the "Readonly" mode, click on the edit button and it goed into edit mode for that row My routine ends with:The update is done and the display refreshes, but in the edit mode. If I click the clancel button back to read only mode.How can I get the gridview to redisplay in the read Only mode after the update?

View 1 Replies

Forms Data Controls :: How To Sort TemplateField Value In GridView

Jun 20, 2010

I want to create simple rating page where player's place,name and rating is displayed. I've created database with ID,Name and Rating Columns, binded Gridview to this database and created TemplateField "Place". With following code I've created numbered list for Place:

protected void Page_Load(object sender, EventArgs e){
for (int i = 0; i < GridView1.Rows.Count; i++)

View 4 Replies

Forms Data Controls :: Pulling The Value Of A TemplateField From A GridView?

Nov 23, 2010

I have a GridView, bound to a table (Meals) in a SqlDataSource.

Into that GridView, I have added a TemplateField, which contains a DropDownList (which displays the numbers 1 - 10, added manually; no Data Binding). And, I've added a ButtonField.

When I click the Button, I want the values of some of the GridView rows PLUS whatever value was selected in the DropDownList to be pulled out and stored in a second Sql table (Orders).

Pulling the rows bound to the SqlDataSource is easy but JavaScript is needed (I think) to pull the SelectedValue from the DropDownList. I understand women more than understand JavaScript (that's how little I know) and the code below has been kindly offered by another forum user who is at a loss, himself, now.

Here's the code and the error message I'm getting.

ASPX:

[Code]....

And here's the Code Behind:

[Code]....

No design time errors reported but here's the run time error:

Object reference not set to an instance of an object.

On the following line:

Line 28: if (row.RowType == DataControlRowType.DataRow)

View 6 Replies

Forms Data Controls :: Gridview Add Templatefield Dynamically?

Mar 11, 2011

[Code]....

[Code]....

I want to add two image button in the TemplateField.. and add it in the gridview.

View 3 Replies

Forms Data Controls :: Dynamically Add A TemplateField To The Gridview?

Dec 15, 2010

I have dynamically created my gridview in the codebehind.

All is working correctly.

I now need to dynamically add a TemplateField to the gridview and populate it with a Button.

I have the following code so far:

TemplateField tempField = new TemplateField();
Button btnRemove = new Button();

View 4 Replies

Data Controls :: Export GridView With TemplateField Containing HyperLinks

May 17, 2013

how can i export by remove the coloumn and rows hyperlink when export to CSV

View 1 Replies

Data Controls :: How To Get Values From TemplateField Column In GridView

May 7, 2015

How to retrieve data from itemtemplate of gridview

View 1 Replies

Forms Data Controls :: TemplateField In Gridview Not Passing DataKey Value?

Feb 4, 2010

I'm relatively new to the VS environment. I'm using VS2010 Beta 2 with VB. I have a Gridview setup to pull a list of employees. Next to their name I have edit and delete icons. When I leave the icons as ButtonFields, they pass the DataKey value to my code behind perfectly. When I convert the ButtonFields to TemplateFields, they no longer pass the DataKey.

[Code]....

[Code]....

[Code]....

View 2 Replies

Forms Data Controls :: Set Value - Label Inside GridView TemplateField

Mar 9, 2011

I have problem while set or passing value from code behind to asp:label inside gridView asp:templateField. 1st. I have gridView and using SqlDataSource control for data source. This is my gridView code?

[Code]....

2nd. I have SqlDataSource for my GridView. this is the code :

[Code]....

We can set value in the *.aspx or design view by using <%# bind("str_isi") %> like the asp:label control with ID=lblGvPengumuman but how we can set value in code behind?

View 7 Replies

Forms Data Controls :: Sorting Gridview Column Templatefield?

Jun 16, 2010

i want to sort a gridview column which is a template field with a repeater control in it. this column has multiple links and i would like to sort using the first link. how can i achieve this.

here is my code:

<asp:TemplateField HeaderText="Groups">

View 2 Replies

Forms Data Controls :: Reverse TemplateField Conversion In A GridView?

Feb 15, 2010

Though it is usually not a big deal to edit the source code to accomplish this, I am just curious if there is an easier way to reverse the conversion of a column to a TemplateField. The covnersion can be done by a simple click. Is there a similar click to reverse it?

View 3 Replies







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