On Jan 7, 11:10*am, Mel <MLights...@gmail.com> wrote:
> When the GridView link button is clicked I want to first set a textbox
> to a value and then call a Javascript function. *How do I do this?
>
> I have a GridView with one column that contains a link button (called
> lbutFabNum) in the ItemTemplate. *When the user clicks lbutFabNum I
> want to set a text box value to the lbutFabNum text and then call the
> Done() javascript function.
Nevermind, I figured it out. Here is the code if anyone else is
interested.
JAVASCRIPT CODE (IN ASPX FILE)
function userSelected(fabnum)
{
document.getElementById('txtEntry').value=fabnum; //set
the text box to the value from the GridView link button
Done(); //call the Done Javascript function to pass the
fab number back to the parent window
}
VB.NET CODE (IN ASPX.VB FILE)
Protected Sub gvJobMaster_RowDataBound(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles
gvJobMaster.RowDataBound 'this is my GridView Control
If (e.Row.RowType = DataControlRowType.DataRow) Then
Dim seldata As String = e.Row.DataItem(0).ToString 'get
column zero data (link button value)
e.Row.Attributes.Add("onclick", "userSelected('" + seldata
+ "')") 'call javascript function
End If
End Sub
|