I have a gridview. When I click on one line, I have to go to javascript, which looks like this.
<script type="text/javascript" language="javascript">
function GetDetails(rowNo)
{
document.getElementById('hidRowNo').value = rowNo
document.getElementById('btnDet').click();
}
</script>
I wrote the following code in codebehind
protected void btnDet_Click(object sender, EventArgs e)
{
if (hidRowNo.Value != "")
{
int rowNo = Convert.ToInt32(hidRowNo.Value);
TextBox1.Text = GridView1.Rows[rowNo].Cells[0].Text;
TextBox2.Text = GridView1.Rows[rowNo].Cells[1].Text;
TextBox3.Text = GridView1.Rows[rowNo].Cells[2].Text;
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onclick", "GetDetails(" + e.Row.RowIndex + ");");
}
}
The problem is javascript working, but document.getElementById ('btnDet'). click (); does not work. At the same time, the debugging also does not go into btnDet_Click. Which change should I include in order to move the control to btnDel_Click in the code behind.
can anyone help?
source
share