I have a gridview that is successfully displaying First and Last Names in a column... I have some Javascript that is successfully writing to another forms text boxes everything except this particular column reaad... any ideas? thanks
The textbox is on another form and is successfully being populated for items 4-5 below but not for item 6's textbox.... can I make the concatonation of the first and last names in my shown query that provides the data accessible to the cells in the datagrid
(working well)... in other words can I alter my query to meet the needs of the javascipt?
selectcommand="SELECT [Unit_Price], [Software_Description], [EndUserFirstName],
[LAN_ID], [EndUserLastName] FROM [tblTransactions] WHERE ([EndUserLastName] = @EndUserLastName)">
Eugene1968
Member
90 Points
360 Posts
reading from Gridview using Javascript
Nov 15, 2012 09:06 PM|LINK
I have a gridview that is successfully displaying First and Last Names in a column... I have some Javascript that is successfully writing to another forms text boxes everything except this particular column reaad... any ideas? thanks
<asp:SqlDataSource
ID="SqlDataSource1"
runat="server"
connectionstring="<%$ ConnectionStrings:TrackITConnectionString %>"
selectcommand="SELECT [Unit_Price], [Software_Description], [EndUserFirstName],
[LAN_ID], [EndUserLastName] FROM [tblTransactions] WHERE ([EndUserLastName] = @EndUserLastName)">
<SelectParameters>
<asp:ControlParameter ControlID="txtLastname" Name="EndUserLastName"
PropertyName="Text" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<script language="javascript">
function GetRowValue(val1, val2, val3, val4, val5, val6) {
window.opener.document.getElementById("txtUserLanId").value = val1;
window.opener.document.getElementById("txtEndUserFirstName").value = val2;
window.opener.document.getElementById("txtEndUserLastName").value = val3;
window.opener.document.getElementById("txtSoftwareDescription").value = val4;
window.opener.document.getElementById("txtTransferFrom").value = val5;
window.opener.document.getElementById("txtUnitPrice").value = val6;
window.close();
}
</script>
<script runat="server">
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles Gridview1.RowDataBound
If (e.Row.RowType = DataControlRowType.DataRow) Then
DirectCast(e.Row.FindControl("btnSelect"), Button).Attributes.Add _
("onclick", "javascript:GetRowValue('" & e.Row.Cells(1).Text & "','" & e.Row.Cells(2).Text & "','" & e.Row.Cells(3).Text & "','" & e.Row.Cells(4).Text & "','" & e.Row.Cells(5).Text & "','" & e.Row.Cells(6).Text & "')")
End If
End Sub
</script>
<asp:TemplateField HeaderText="Full Name" SortExpression="Full Name">
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("EndUserFirstName").ToString + " " + Eval("EndUserLastName").ToString %>'></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("EndUserFirstName").ToString + " " + Eval("EndUserLastName").ToString %>'></asp:Label>
</ItemTemplate>
<ItemStyle CssClass="gridview_body_font" HorizontalAlign="Center"
Width="100px" />
</asp:TemplateField>
sarathi125
Star
13599 Points
2691 Posts
Re: reading from Gridview using Javascript
Nov 16, 2012 07:43 AM|LINK
Hi,
<EditItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Eval("EndUserFirstName").ToString + " " + Eval("EndUserLastName").ToString %>'></asp:Label> </EditItemTemplate>In the edit template also you having only label, then where is the textbox, that you have mentioned in the javascript.
Remember to click Mark as Answer on the post that helps to others.
My Blog :MyAspSnippets
Eugene1968
Member
90 Points
360 Posts
Re: reading from Gridview using Javascript
Nov 16, 2012 11:43 AM|LINK
The textbox is on another form and is successfully being populated for items 4-5 below but not for item 6's textbox.... can I make the concatonation of the first and last names in my shown query that provides the data accessible to the cells in the datagrid (working well)... in other words can I alter my query to meet the needs of the javascipt?
selectcommand="SELECT [Unit_Price], [Software_Description], [EndUserFirstName],
[LAN_ID], [EndUserLastName] FROM [tblTransactions] WHERE ([EndUserLastName] = @EndUserLastName)">
<script language="javascript">
function GetRowValue(val1, val2, val3, val4, val5, val6) {
window.opener.document.getElementById("txtUserLanId").value = val1;
window.opener.document.getElementById("txtEndUserFirstName").value = val2;
window.opener.document.getElementById("txtEndUserLastName").value = val3;
window.opener.document.getElementById("txtSoftwareDescription").value = val4;
window.opener.document.getElementById("txtTransferFrom").value = val5;
window.opener.document.getElementById("txtUnitPrice").value = val6;
window.close();
}
</script>