Validation For DataGridview Values Before Insert To DataBase
DataGridview Add Directly To RunTime Validation Null Values Avoid To Insert DataBase Using C# Window Applicatio.
DEMO
C# CODING
Next - Add New Window Form - Select DataGridView - EditColumn - Add Field Name & Header Text
Next - Created DataGridView Column
Next - DataGridview - Event - Select RowValidating Click
Next - Add DataGridView Validating Null Values
Next - Run [F5] The Program - Validation for DataGridView
DataGridview Add Directly To RunTime Validation Null Values Avoid To Insert DataBase Using C# Window Applicatio.
DEMO
C# CODING
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApplication2
{
public partial class Home11 : Form
{
public Home11()
{
InitializeComponent();
}
private void Home11_Load(object sender, EventArgs e)
{
}
private void dataGridView1_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
{
if ((dataGridView1[0, e.RowIndex].Value == null) || (dataGridView1[1,
e.RowIndex].Value == null))
{
//
e.Cancel = true;
MessageBox.Show("Fill Empty
Row");
}
}
private void button1_Click(object sender, EventArgs e)
{
if (dataGridView1.Rows.Count>1)
{
//
Your Insert Command
MessageBox.Show("Data
Saved");
}
}
}
}
Next - Created DataGridView Column
Next - DataGridview - Event - Select RowValidating Click
Next - Add DataGridView Validating Null Values
Next - Run [F5] The Program - Validation for DataGridView
https://allittechnologies.blogspot.in/2015/08/csharp-net-interview-questions-and-answer-for-freshers-and-experience.html
ReplyDelete