0

i want when i click on a row on gridview send it's id to javascript. for this work i override the rowdatabound event like this:

 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{

    GridView1.Attributes.Add("onclick", "javascript:test('"e.Row.ClientID"')");
}

but it don't working and have errors! in vb i used from & to solving this problem like this:

   GridView1.Attributes.Add("onclick", "javascript:test('" & e.Row.ClientID & "')");

what can i do in c#?

1 Answer 1

1

In C# you should use + for string concatenation, so try this:

GridView1.Attributes.Add("onclick", "javascript:test('" + e.Row.ClientID + "')");
Sign up to request clarification or add additional context in comments.

1 Comment

javascript: is not needed in events. Also i don't know what Row.ClientID contains but if it has a ' inside the script will break.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.