views:

45

answers:

1

Using Datagrid I am trying Web Form on click datagrid row, Any body suggest how I do this.

A: 

Add javascript click-eventhandler for a row

Code behind

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if(e.Row.RowType == DataControlRowType.DataRow )
    {            
        User selUser = e.Row.DataItem as User;
        e.Row.Attributes.Add("onclick","openWindow('" + selUser.Id + "')");
    }
}

Javascript function

<script language="javascript">


        function openWindow( userId )
        {
            var url= "http://www.google.com";
            newwindow=window.open(url,'name','height=400,width=200');
        if (window.focus) {newwindow.focus()}
        }


    </script>
Pranay Rana