I have a GridView and am needing to grab column 1 and 2 (the text therein) and put that text elsewhere in the page, another textbox.
Here is what I have thus far:
var checked = $('input:checkbox').click(function(e) {
//place airport in textbox, txtAirport
var loc = $("tr:has(:checkbox:checked) td:nth-child(1)");
var ac = $("tr:has(:checkbox:checked) td:nth-child(2)");
// txtAirport.Text = loc + ac;
$("#<%= txtAirport.ClientID%>").val(loc + ac);
});
the problem is I am getting {Object object} {Object object} in my textbox where I'm expecting to get a city, st and an airport. How do I clarify my "loc" and "ac" variables to give me what I need? I've tried .text and .val() to no avail.
Here is the HTML (ASP.NET Gridview):
<asp:DataGrid ID="dgSearch" runat="server" AllowPaging="False" AllowSorting="False"
CellPadding="3" CellSpacing="2" ShowFooter="False" GridLines="None" AutoGenerateColumns="false">
<AlternatingItemStyle Wrap="False" CssClass="HeaderRowAlternate"></AlternatingItemStyle>
<ItemStyle Wrap="False"></ItemStyle>
<HeaderStyle Font-Bold="True" Wrap="False" CssClass="HeaderRowStyle"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="Select">
<HeaderStyle CssClass="HEADERSTYLE"></HeaderStyle>
<ItemTemplate>
<asp:CheckBox ID="chkLookup" runat="server" CssClass="checkbox"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn Visible="False" DataField="AirportID"></asp:BoundColumn>
<asp:BoundColumn Visible="False" DataField="City"></asp:BoundColumn>
<asp:BoundColumn DataField="Loc" HeaderText="Location">
<HeaderStyle Wrap="False" CssClass="HEADERSTYLE"></HeaderStyle>
<ItemStyle Wrap="False"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="AirportCode" HeaderText="Airport Code">
<HeaderStyle Wrap="False" CssClass="HEADERSTYLE"></HeaderStyle>
<ItemStyle Wrap="False"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="AirportName" HeaderText="Airport Name">
<HeaderStyle Wrap="False" CssClass="HEADERSTYLE"></HeaderStyle>
<ItemStyle Wrap="False"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="MilesFromSource" HeaderText="Distance">
<HeaderStyle Wrap="False" CssClass="HEADERSTYLE"></HeaderStyle>
<ItemStyle Wrap="False"></ItemStyle>
</asp:BoundColumn>
</Columns>
</asp:DataGrid>