When a textbox column of a GridView is written out to the browser, the Id's of the text boxes are generated automatically by ASP.NET. The solution to your problem is letting the javascript calendar know the id of the textbox sitting next to it, in the same row of the grid. You can do this in the RowDataBound event of the GridView which is fired as the data for each row of the GridView is bound.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// Access textbox here and assign onclick ...
}
}
Once you access the TextBox you can assign the onclick event to it with the appropriate client side textbox Id.
myTextBox.Attributes\["onclick"\] = "popUpCalendar(this, " + myTextBox.ClientId + ", \\"dd/mm/yyyy\\")";
Use the ClientId property on the server side to get the id of the textbox which will be written to the browser for that particular row. By examining the source of the web page you will see that the onclick for each row will have the correct id for the associated textbox.
Declan Bright www.declanbright.com