在C#Windows应用程序中更改放置在gridview内的文本框值

时间:2019-01-09 07:27:01

标签: c# asp.net

如何更改放置在gridview值内的文本框,如果该值不是数字,我希望文本框在该列位置放置0

private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
    if (e.ColumnIndex == 1) // column to check for only numeric values
    {
        int i;

        if (!int.TryParse(Convert.ToString(e.FormattedValue), out i))
        {
            e.Cancel = true; // halting the tool till correct value in the cell but I want that instead of this line I want to place a value in that cell

        }
        else
        {
           // the input is numeric 
        }
    }
}

0 个答案:

没有答案