Problem in extracting null value from a grid view field to add to a database table field

Hi,
I have a grid view and I am extracting a field value from the gridview corresponding to the chosen record via a radio button. Now for a particular record the field in grid view in asp.net is showing null value (blank). However when I am extracting this field value to add it to a database table the field in the table is populated by "&nbsp". I would like the field to be populated with null or even "". I am not sure how to do this.

The following approach is failing:

           If SelectedGridRow.Cells(5).Text = "&nbsp" Then
                SelectedGridRow.Cells(5).Text = ""
            Else
                Response.Write("Checking if statement")
            End If
           
 Any help is appreciated.

0
gamaz
12/4/2008 5:10:54 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

3 Replies
1226 Views

Similar Articles

[PageSpeed] 27

 Have you tried

 

If SelectedGridRow.Cells(5).Text = " " Then
    SelectedGridRow.Cells(5).Text = ""
Else
    Response.Write("Checking if statement")
End If
  
0
BMeyerKC
12/4/2008 5:23:39 PM

"&nbsp" is empty space character.

You can try this way.. 

SelectedGridRow.Cells(5).Text.Replace(" ", "") 'removes all empty spaces
 

My Blog


"Don't be afraid to be wrong; otherwise you'll never be right."
0
budugu
12/4/2008 5:30:46 PM

Thanks for each of your help folks. However the solution did not work with your example. Then I checked my code and saw I made a mistake. I forgot to put the ; after the expression "&nbsp. Putting the semicolon took care of the issue. Thanks

 

0
gamaz
12/4/2008 7:38:54 PM
Reply:

Similar Artilces:

Submitting Web forms fields to sql database by clicking on SUBMIT FORM and sending the form fields to email box
I have a created or designed a form to be stored in a SQL database table and at the same time when a user clicks on SUBMIT button the form fields will automatically goto the visitor email address immediately. Also i have created a database with tables for each of this forms Pls help i have over 10 forms designed but the problem of submitting them to the table database and the user email address is the challenge now.... You ned to familiarise yourself with the basics of database access in ASP.NET.  There are free tutuorials here: http://quickstarts.asp.net/QuickStartv20/aspnet/doc/da...

Drop down list in Form view returns error when value in bound field (data binding
I get the following error when I click edit to edit the details in the web form:'ddlUserRestrictionType' has a SelectedValue which is invalid because it does not exist in the list of items.Parameter name: value  I would like it to accept any value which currently exists in the database. Is this easily achievable? With what you've posted, all I can tell is that you are trying to set the SelectedValue of a ddl to a value that does not exist in the list.  It would be helpful if you can post some code and the expected values of this control.~ Timwww.bucketo...

How to pass null value to the database if a form field is empty?
How can I pass into the database (@User_fax = null) if the fax form field is empty, from a command type Stored Procedure? For example: Dim CmdUpdate As New SqlCommand("Form2_NewUser", strConnection) CmdUpdate.CommandType = CommandType.StoredProcedure CmdUpdate.Parameters.Add("@User_fax", SqlDbType.char, 9) CmdUpdate.Parameters("@User_fax").Value = fax.Text() .... strConnection.open() CmdUpdate.ExecuteNonQuery strConnection.close() And, the stored procedure inside Sql server: USE market1 GO ALTER PROC Form2...

Hiding a web form field based on database value.
  Hi, i want a textbox to be hidden based on the user access ID, and if the admin has clicked on a checkbox which makes it deactivated. I have the following; Code behind which displays all the fileds;private void DisplaySelectedRecord(DataView dv) { //populate the controls on the page to show the data on the page controls  this.txtMA_Code.Text = dv[0]["MA_Code"].ToString().Trim();   this.txtRate.Text = dv[0]["Rate"].ToString() ;if (dv[0]["Rate_Active"] != null && dv[0]["Rate_Active"] != System.DBNull.Value)this.CheckBox1...

Insert NULL value into datetime field of Oracle database
 Hi all,I have a form which has a textbox where a date is entered by the user - this field is not compulsory so if it is left blank I want to store it in the table as nothing. However, when I use the code below it enters 01/01/0001 instead of nothing. I have tried various other options Endate.MinValue and EndDate = System.DBNull.Value (this throws an error)Im stumped. Anyone have any ideas as to how I can enter a blank value into a date field in my oracle table? Would prefer to do it before I go near the sql Insert (so in my vb.net code) because thats done using a stored procedure and w...

How to add several form field values to email being sent in vb.net?
I have a form that sends an email when the submit button is clicked.  I'd like to include the values from the form into the text of the email, but I don't know how to do that.  Below is the code I have to send the email... How do I add all the form values to the message text  (mm.Body) and include line breaks or spacing to layout the form values for easy reading?  Protected Sub Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Submit.ClickConst ToAddress As String = "foo@foo.com"Dim mm As New MailMessage("foo@foo.com&q...

How can I add 2 fields value to 1 fields value in a GridView?
Hi all!I have one access database named=Medlemmar.mdb and Tablename=TidBokning and with some columns ex. "Bokad_For" and "Plats".Let say that "Bokad_For" contains value "Group2" and "Plats" contains value "Stockholm".Now I want to make this 2 value to 1 fileds like this: "Bokad_For" contains value "Group2Stockholm"How can I do that?I use asp.net 2.0 and C#.I tried with Eval("Bokad_For") and somthing, but Eval works only in Templates (I guess) I cant get Templates to work in my GridView.i'm newbee in this and think I need some help here :-) ?Thanks for all help!Micael Roxenhall You can sol...

How to make the form View save it's field values in Visual Stdio .NET
Hi every one .this's my first post in this forum ,hope you can help me ..i have this problem ,i have a form View that i use to insert data into a data base ,the thing is: i want the text values inserted in the Text Fields in the Insert Template in The Form View to be saved ,meaning that when the insert operation completes these text field still contain the text values that was inserted in ..note : i tryed to enable the view State in those TextBoxes but that didn't work ..  I think it's about SqlDataSource Refreshing  the FormView or Some thing like that ,but i don'...

Passing Web Form TextBox value to a SQL Server 2000 Table column field
Community, I am trying to pass a text box value to populate a table column called LastName - see below - using the Update command.  When the below code executes from the Web Form, 'LastName.Text' populates the table column.  I, of course, want the value in the txtLastName.Text field.  Any advice is appreciated! Dim strSQL As New SqlCommand("UPDATE Clients" & _ " SET LastName = 'txtLastName.Text' " & _ " WHERE AccountID =" & txtAccountNo.Text, scnnNW) Rob H. Change: " SET LastName = 'txtLastName.Text' " & _ to " SET LastName...

how to design vb.net form with two fields that need to have ability to add a limitless number of values.
I have a form with 5 textboxes and 2 fields that need to have an endless number of options and I just don't know how to deal with this all on one form.  Questions 1-5 are basic demo graphic questions about a person (Name, address, etc) Question 6 asks you to provide insurance beneficiaries and their percentage, and there is no limit to the number of insurance beneficiaries you can have.  (You could list 100 beneficiaries, with each getting 1%) Question 7 asks the user to provide 401k benficiaries and their percentage, and again, there is no limit to the number you can have, ...

Poplate a grid with fields from a custom field table
Is it possible to populate a grid with fields and specific controls if I don't know the field name or datatype? I have a table tblCustomFields. A user can add their own fields to this table. They enter a name and select from five datatypes, nvarchar, money, datetime, int, or bit. I have figured out how to get the field names and datatypes of the custom fields the use has added. But I have now idea how I would create a grid to show the fields and the appropriate control type so a user could then add data to the fields. I suppose it would not need to be a grid, but the same thing applies, ho...

Updating a table field with a computed field value
In a datawindow, how do I update a field in a table with the value from a computed field ? Thank you. Joe Thank you very much. That's the answer I was looking for. Joe Ippolito In updatestart , or in update button, you can use getitem() and setitem() functions to get the value and set it in field. You can't achieve this directly in datawindow. hth -- Mahendra Dhamdhere Unicef, New York Email:mahendrad@hotmail.com Joseph Ippolito wrote: > In a datawindow, how do I update a field in a table with the value > from a > computed field ? Thank ...

DetailsView: conditionally hide field if value == null, but can't update the value of other fields
Hi, I need help please. I have made some fields hidden if their value is null by setting visible to false on the DetailsView1_Itemcreated event. I put the field's to the DataKeyNames, so that I can check the value is null or not when detailsview is at the readOnly mode.But, when I tried to edit, it throws an error: must declare a scalar for @...  so, i add some code in the DetailsView1_ItemUpdating: e.newValues["color"] = null; then the error is gone. but, the values for other fields are not updated. I already check the e.newValues["other fields"] , they all are ...

ADO.net problem: i can not view image data for the rest of my table rows except the image for the first row but i can read all the other non image fields for all rows.
Hi i have a table with the following fields imgid............int imgdata........image imgtitle.........varchar(max) imgType........varchar(max) imgLength.....bigint incident_id.....int i have no problem with uploading the image but viewing the uploaded image(s) in a gridview has caused me great pain. The probelm is i have two pages. page1 grabs the image to display and page2 has a gridview that displays the grabed image. I wanted to have an sql statement like SELECT * FROM mytable WHERE incident_id=someValue. IF i have 5 records in this table and i view page2 ...

Web resources about - Problem in extracting null value from a grid view field to add to a database table field - asp.net.web-forms

Local Measure addresses the importance of extracting value from Big Data
There are many opportunities surrounding the Big Data space and if businesses milk the value from all the data they’ve got, it can change the ...

Dentist deregistered after extracting teeth and performing root canal work without patients’ consent
A DOWN-in-the-mouth dentist who extracted wisdom teeth and performed root canal work on patients without their consent has been deregistered ...

Extracting the digital
Alexa Moses tries to make sense of the Resfest digital film festival. - Sydney Morning Herald Online

Shy bidders' tactics make extracting bids almost as painful as dental work
Shy bidders' tactics make extracting bids almost as painful as dental work

Brookfield 'ruthless' in extracting infrastructure profits, says CBH
The nation's biggest grain exporter CBH Group has thrown its weight behind concerns by farmers over Brookfield's $8.9 billion proposed takeover ...

Companies extracting B.C. groundwater for free
Several groups are calling on the province to tighten groundwater laws as B.C. is the only jurisdiction in Canada that does not charge major ...

Extracting info: Why’s it so hard to get the goods on oil spills?
It can be tough to get a good sense of how safe Alberta’s oil industry is when you can’t access the information you need.

Krugman on extracting a price for intellectual dishonesty
Just a small point, but with it I want to make a larger one. ■ The small point is about Paul Krugman and his slow path to calling out his professional ...

When Oil Isn’t Worth Extracting
... the point at which energy resources become too costly to take out of the earth: We’ll never run out of any fossil fuel, in the sense of extracting ...

Revenge is ours: extracting energy from a cockroach
... inside it to use it as a mini-electricity generator. Now, I hate cockroaches as much as anyone, and there is a certain satisfaction in extracting ...

Resources last updated: 12/8/2015 7:14:55 AM