1 Replies - 1155 Views - Last Post: 07 December 2012 - 04:31 AM

#1 G_rose42  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 51
  • Joined: 15-December 10

how to access gridview control from clientside javascript

Posted 07 December 2012 - 12:30 AM

I have to access the label from gridview emptydatatemplate using javascript or jquery to change the label text. when button onclientclick event .i have this button outside the gridview.
like below:-

<script type="text/javascript">

//button1 OnClientClick function call

function fun_AddnlFeeChange()
{
//When this client function call i need to change the EmptyDataTemplate additional fees label value

//I need to bind some calculation value in that additional fee label
return false;
}

</script>

<table>
<tr>
<td colspan="10" align="center">
<asp:GridView ID="gv_CreateNewPO" runat="server" AutoGenerateColumns="False" GridLines="None"
ShowFooter="True" Width="100%">
<EmptyDataTemplate>
<table border="0" cellpadding="0" cellspacing="0" align="left" width="100%">
<tr>
<th align="left" class="tableheadernew">
Line #
</th>
<th align="left" class="tableheadernew">
Price Ref.#
</th>
<th align="left" class="tableheadernew">
Addnl. Fees
</th>
<th align="left" class="tableheadernew">
Cert/Srvc
</th>
<th align="left" class="tableheadernew">
Note
</th>
<th align="left" class="tableheadernew">
</th>
<tr>
<td>
<asp:Label ID="lbl_CNPOLineNo" runat="server" Text="1">
</asp:Label>
</td>
<td class="Rowstyle">
<asp:TextBox ID="txt_CNPOPriceRef" runat="server" ></asp:TextBox>
</td>
<td>
<asp:Label runat="server" ID="lbl_AddnlFees"></asp:Label>
</td>
<td class="Rowstyle">
<asp:LinkButton ID="lnk_CertSrvc" runat="server">Enter</asp:LinkButton>
</td>
<td class="Rowstyle">
<asp:LinkButton ID="lnk_Note" runat="server">Enter</asp:LinkButton>
</td>
<td class="Rowstyle">
<asp:LinkButton ID="lnk_Save" runat="server">Save</asp:LinkButton>
</td>
</tr>
<tr>
<td class="tablefooterfinal" colspan="17">
</td>
</tr>
</tr>
</table>
</EmptyDataTemplate>
</asp:GridView>
</td>

<tr>
<tr>
<td align="center">
<asp:Button ID="Button1" runat="server" Text="Process" OnClientClick="return fun_AddnlFeeChange();" />
</td>
</tr>
</table>


Is This A Good Question/Topic? 0
  • +

Replies To: how to access gridview control from clientside javascript

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,226
  • Joined: 08-June 10

Re: how to access gridview control from clientside javascript

Posted 07 December 2012 - 04:31 AM

for Java​Script it doesn’t matter where the element of interest is in the server side language. as long as it is in the HTML code (not the ASP code!) you can access it. one of the simple methods is giving that label an ID, so you can use document.getElementById(), you also could layaway through the DOM tree.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1