Resources » .NET programming » Visual Studio

ValidatingEditor in Xtragrid in VB.NET


Posted Date:     Category: Visual Studio    
Author: Member Level: Silver    Points: 20


In this article, I will explain how to perform a ValidatingEditor in an xtragrid in VB.NET If we are having a datagrid and we are trying to edit the cells. Sometimes it occur that "Input string was not in a correct format" error with a cross symbol in the cell.



 


Validating Editor in DevExpress Gridview



In this article, I will explain how to perform a ValidatingEditor in an xtragrid in VB.NET

If we are having a datagrid and we are trying to edit the cells.
Sometimes it occur that "Input string was not in a correct format" error with a cross symbol in the cell.

Mostly it occurs with numerical values and when we make the column null, the above said error occurs.

So what shall we do if we want to make the cell empty ?

To do that, write the following code for the particular grid.


Private Sub GridView1_ValidatingEditor(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventArgs) Handles GridView1.ValidatingEditor

Dim view As GridView = CType(sender, GridView)
If view.FocusedColumn.FieldName = "id" Or _
view.FocusedColumn.FieldName = "phno" Then

If Not e.Value Is Nothing AndAlso e.Value = "" Then
e.Value = DBNull.Value
End If
End If
End Sub


Now you can give null values to the cell.

Also, when storing those null values to the database, give the sql query like the following code :


For each drow as DataRow in dt.Rows
If Convert.ToString(drow("id")) = "" And _
Convert.ToString(drow("phno")) = "" Then
Dim sqlText as String = "UPDATE table SET id = " & "NULL" & _
" AND phno = " & "NULL"
.....
End If
Next


so it will store Null in the database.
Some columns will not allow nulls.
In such cases 0 may be stored





Did you like this resource? Share it with your friends and show your love!


Responses to "ValidatingEditor in Xtragrid in VB.NET"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: How to drag and drop multiple rows from xtragrid to xtratreelist in VB.NET?
    Previous Resource: Sending email from an application using VB.NET
    Return to Resources
    Post New Resource
    Category: Visual Studio


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    Input string was not in a correct format  .  ValidatingEditor in Xtragrid in VB.NET  .  
    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.