Hi Anand,
Using the below steps, you can achieve your result,
1. Add onclientclick with a javascript function with the current object as below,
<asp:button id="btnSave" runat="server" text="Save" onclientclick="javascript:return ValidateFields(this);"/>
2. Whenever you click this button, it will call the javascript function. In this function, you have to validate all of your grid view control fields here. Finally, if there is no error then return false otherwise return true.
3. If you don't mention the return statement then it calls your codebehind function
In javascript, you can find your gridview control as follows,
1. While calling the function it pass the current button control object as a parameter
2. $(CurrentObj).id using this code you can get the id of that button
3. Now, in same row all other control id will be same only the name needs to change. Below, is the example of the control name,
<asp:dropdownlist id="dropdown1"/>
<asp:dropdownlist id="dropdown2"/>
<asp:button id="btnSave" runat="server" text="Save" onclientclick="javascript:return ValidateFields(this);"/>
In javascript function you will get the btnSave ID something like this,
ct100_btnSave_100
Now, you can just replace the id "btnSave" to "dropdownlist1" you can get the value of the dropdown list control.
Like this, you can get all the fields and you can validate it.
Let me know if you have any questions.
Regards,
V.M. Damodharan
"Your talent will be worthless, when you have fear and tension."