Hi makumbi,
Inorder to use Switch statement you need to set the class name for the TextBoxes.
Then inside the Switch statement you need to check with control classname.
Refer below code.
HTML
<asp:GridView ID="gvCustomers" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="Id">
<ItemTemplate>
<asp:TextBox ID="txtId" runat="server" Text='<%#Eval("Id") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<asp:TextBox ID="txtName" runat="server" Text='<%#Eval("Name") %>' CssClass="name" ></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Country">
<ItemTemplate>
<asp:TextBox ID="txtCountry" runat="server" Text='<%#Eval("Country") %>' CssClass="country" ></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
JavaScript
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (prm != null) {
prm.add_endRequest(function (sender, e) {
if (sender._postBackSettings.panelsToUpdate != null) {
var rowIndex = parseInt(document.getElementById("hfRowIndex").value);
var row = document.getElementById("gvCustomers").rows[rowIndex + 2];
if (typeof (row) != "undefined") {
var controls = row.getElementsByTagName("INPUT");
for (var i = 0; i < controls.length; i++) {
switch (controls[i].className) {
case "name":
break;
case "country":
break;
default:
}
}
}
}
});
};