You should be able to get the ID of the TextBox in the FooterRow without having to loop through all of the elements on the page.
Just like you know the ID of the GridView, you also know the ID of the TextBox in the FooterRow.
If you don't actually know how to get this value, it's the ClientID property ;)
For example:
editgrid.ClientID will return "ctl00_BodyContent_editgrid" (the ID of your GridView)
So:
theTextBoxInTheFooterRow.ClientID will return you something similar to "ctl00_BodyContent_editgrid_ctrl100000theTextBoxIn TheFooterRow".
Since you can retrieve the ID of the text box in this manner, you can pass it to your validation function...or you can directly input it into your validation function...
Here's an example of your function modified to accept ID of the TextBox as a parameter:
-
function validateFooter(textBoxID)
-
{
-
var textBox=document.getElementById(textBoxID);
-
iftextBox.value=="")
-
{
-
alert('Plese Enter the value);
-
return false;
-
}
-
}
There are a few ways to "directly input" it into your validation function.
If your function is in your asp page, you can use the Response.Write method to write the clientID of the TextBox into your function (note that <%= %> as an ASP short hand for calling the Response.Write method):
-
function validateFooter(textBoxID)
-
{
-
var textBox=document.getElementById('<%= textBox.clientID %>');
-
iftextBox.value=="")
-
{
-
alert('Plese Enter the value);
-
return false;
-
}
-
}
Since your TextBox is going to be dynamically added to your page it's probably advisable to use the first way I mentioned (pass the ID to the function) so that in your RowDataBound event you can store the ClientID in a HiddenField.....
Ahh, there's so many ways to do this....