Hi jamess,
Here i have created sample that full fill your requirement.
HTML
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowCancelingEdit="OnRowCancelingEdit"
OnRowEditing="OnRowEditing" AutoGenerateEditButton="True">
<Columns>
<asp:TemplateField HeaderText="Id">
<ItemTemplate>
<asp:Label ID="lblId" runat="server" Text='<%# Bind("Id") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblEditId" runat="server" Text='<%# Bind("Id") %>'></asp:Label>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="First Name">
<ItemTemplate>
<asp:Label ID="lblFirstName" runat="server" Text='<%# Bind("FirstName") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtFirstName" runat="server" Text='<%# Bind("FirstName") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Last Name">
<ItemTemplate>
<asp:Label ID="lblLastName" runat="server" Text='<%# Bind("LastName") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtLastName" runat="server" Text='<%# Bind("LastName") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<asp:Label ID="Label1" runat="server" />
</div>
Code
Protected Sub Page_Load(sender As Object, e As EventArgs)
If Not Me.IsPostBack Then
PopulateGrid()
End If
End Sub
Private Sub PopulateGrid()
Dim dt As New DataTable()
dt.Columns.AddRange(New DataColumn(2) {New DataColumn("Id", GetType(Integer)), New DataColumn("Firstname", GetType(String)), New DataColumn("Lastname", GetType(String))})
dt.Rows.Add(1, "John", "1")
dt.Rows.Add(2, "Mudassar", "1")
dt.Rows.Add(3, "Suzanne", "0")
dt.Rows.Add(4, "Robert", "1")
GridView1.DataSource = dt
GridView1.DataBind()
End Sub
Protected Sub OnRowEditing(sender As Object, e As GridViewEditEventArgs)
GridView1.EditIndex = e.NewEditIndex
PopulateGrid()
End Sub
Protected Sub OnRowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs)
GridView1.EditIndex = -1
PopulateGrid()
Label1.Text = String.Empty
End Sub
Protected Sub OnRowUpdating(sender As Object, e As GridViewUpdateEventArgs)
GridView1.EditIndex = -1
PopulateGrid()
Dim result As GridViewRow = GridView1.Rows.Cast(Of GridViewRow)().Where(Function(x) TryCast(x.FindControl("lblLastName"), Label).Text = "0" OrElse String.IsNullOrEmpty(TryCast(x.FindControl("lblLastName"), Label).Text)).FirstOrDefault()
If result IsNot Nothing Then
Label1.Text = "Bad"
Else
Label1.Text = "Good"
End If
End Sub
Screenshot
