I have a label and I stored value from it through backend coding. I want to get the value of label and pass to Javascript. Please Help me. Everything works find but when I add update panel they now showing 0 value. I need to put update panel so that the page won't refresh every gridview row clicked.
Here is what I have so far.
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="my_graph" runat="server"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" class = "grd-view table table-hover" OnRowDataBound="GridView1_RowDataBound" OnSelectedIndexChanged="Gridview1_OnSelectedIndexChanged" runat="server">
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<div id="chartContainer" style="height: 150px; width: 100%;"></div>
JavaScript
var pie = 0;
function changepie(val) {
pie = val;
}
function pageLoad() {
alert(pie)
}
BackEnd
Protected Sub Gridview1_OnSelectedIndexChanged(sender As Object, e As EventArgs) Handles GridView1.SelectedIndexChanged
Dim percent As String = GridView1.SelectedRow.Cells(6).Text
my_graph.Text = percent
ClientScript.RegisterClientScriptBlock(Me.[GetType](), "Script", "changepie(" + my_graph.Text + ");", True)
End Sub