0

So I have this asp label like below, created in visual studio 2008

<asp:GridView ID="PopulateGridView" runat="server" CellPadding="4" BorderWidth="1px"
                        CssClass="ControlStyle" ForeColor="#333333" Font-Size="8px"                 
                        GridLines="Vertical" width="99%" CaptionAlign="Left" PageSize="22" 
                        AllowPaging="True" 
                        OnPageIndexChanging="Populate_OnPageIndexChanging"                             
                        OnSelectedIndexChanged="PopulateGridView_SelectedIndexChanged" 
                        OnSelectedIndexChanging="PopulateGridView_SelectedIndexChanging"
                        AutoGenerateColumns="false" 
                        enableEventValidation="true">       
                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" HorizontalAlign="Left" Wrap="False" />
                        <Columns >   
                            <asp:TemplateField HeaderText="User ID">
                                <ItemTemplate>
                                    <asp:Label ID="lblApp_uid" runat="server" Font-Size="10px" CssClass="ControlStyleUpperCase"  Text='<%# Bind("uid") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </columns>
                        </asp:GridView>

And the situation is like this, once a submit button is clicked, there will be popup asking the user to key in something, and when they click on OK button inside the popup, It should pass the data to Javascript like

$(function() {
    e.preventDefault();
    $('#btnInsidePopup').click(function(e) {
        var rmk = $('#rmk').val();
        var uid = $('#lblApp_uid').val()
        /* proceed with function */
    });
});

I manage to get the key-in value using $('#rmk').val() but not the lblApp_uid value, I've tried below method but still unable get it.

var uid = $('#App_uid').val(); 

also this one(below) throw me an error Name 'lblApp_uid' is not declared

var uid = $('#<%=lblApp_uid.ClientID%>').val();

how can I get the value? please help

Tony
  • 119
  • 1
  • 2
  • 13
  • Being within the grid's template, there could be zero or multiple copies of the Label in the finished document. A similar question here should be able to help – "[How do I find the Client ID of control within an ASP.NET GridView?](https://stackoverflow.com/questions/1128746/how-do-i-find-the-client-id-of-control-within-an-asp-net-gridview)" – Jonathan Lonowski Oct 31 '18 at 02:34
  • Is that `rmk` and `btnInsidePopup` exists outside the grid? If it's true, then you cannot use ID property of the label to get it, because item template is used. – Tetsuya Yamamoto Oct 31 '18 at 02:34
  • @TetsuyaYamamoto - yes, those popup is outside the grid, so any Idea? – Tony Oct 31 '18 at 02:36
  • @JonathanLonowski yes, the grid contains more than 1 value. – Tony Oct 31 '18 at 02:37

0 Answers0