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
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");
}
}
}
}
0 comments:
Post a Comment