Mahdi_Nine
Mahdi_Nine

Reputation: 14761

passing parameters from asp.net to javascript

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#?

Upvotes: 0

Views: 1126

Answers (1)

JonoW
JonoW

Reputation: 14249

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

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

Upvotes: 1

Related Questions