using System;
using System.Data;
using System.Windows.Forms;
public class Example
{
public void CheckColumnExists(DataRowView rowView, string columnName)
{
if (rowView == null)
{
Console.WriteLine("DataRowView is null.");
return;
}
DataTable table = rowView.DataView.Table;
if (table.Columns.Contains(columnName))
{
Console.WriteLine($"Column '{columnName}' exists.");
}
else
{
Console.WriteLine($"Column '{columnName}' does not exist.");
}
}
}
public class Program
{
public static void Main()
{
DataTable table = new DataTable();
table.Columns.Add("ID", typeof(int));
table.Columns.Add("Name", typeof(string));
DataRow row = table.NewRow();
row["ID"] = 1;
row["Name"] = "John Doe";
table.Rows.Add(row);
DataRowView rowView = table.DefaultView[0];
Example example = new Example();
example.CheckColumnExists(rowView, "Name");
example.CheckColumnExists(rowView, "Age");
}
}