I have a dropdownlist that when you select the value, allows a select query to be used in the gridview. I am trying to pass the query results to a hidden field and then pass those values to a popup. I have the popup function working and the select but the
problem lies in the hidden field. Whever I try to capture the value it gives me an error. Thanks for the help ^_^
Here is the vb part
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls.WebParts
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
ClientScript.RegisterStartupScript([GetType](), "a", "ButtonClick()", True)
HiddenField1.Value = GridView1.SelectedValue
Dim strQuery = "SELECT [text_course], [text_course_id], [text_contact_hours], [text_credit_hours], [text_des] FROM [Text] WHERE ([text_course] = @text_course)"
End Sub
End Class
battleangela
0 Points
4 Posts
Hidden View Data
Jun 12, 2007 04:08 AM|LINK
Hi
I have a dropdownlist that when you select the value, allows a select query to be used in the gridview. I am trying to pass the query results to a hidden field and then pass those values to a popup. I have the popup function working and the select but the problem lies in the hidden field. Whever I try to capture the value it gives me an error. Thanks for the help ^_^
Here is the vb part
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls.WebParts
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
ClientScript.RegisterStartupScript([GetType](), "a", "ButtonClick()", True)
HiddenField1.Value = GridView1.SelectedValue
Dim strQuery = "SELECT [text_course], [text_course_id], [text_contact_hours], [text_credit_hours], [text_des] FROM [Text] WHERE ([text_course] = @text_course)"
End Sub
End Class
Html Source:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<HEAD>
<TITLE>Popup Example</TITLE>
<SCRIPT LANGUAGE="JScript">
var oPopup = window.createPopup();
function ButtonClick()
{
var oPopBody = oPopup.document.body;
oPopBody.style.backgroundColor = "lightyellow";
oPopBody.style.border = "solid black 2px";
oPopBody.innerHTML = "Click outside <B>popup</B> to close.";
oPopup.show(100, 100, 180, 25, document.body);
}
</SCRIPT>
</HEAD>
<BODY>
<form runat="server">
SELECT [text_course], [text_course_id], [text_contact_hours], [text_credit_hours], [text_des] FROM [Text] WHERE ([text_course] = @text_course)
<button id="alpha" onmouseover="ButtonClick()" style="left: 59px; position: absolute; top: 157px">Move OVer</button>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:Con+PorjectConnectionString1 %>"
ProviderName="<%$ ConnectionStrings:Con+PorjectConnectionString1.ProviderName %>"
SelectCommand="SELECT [text_course], [text_course_id] FROM [Text] WHERE ([text_course] = @text_course)">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="text_course" PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource3" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2" ForeColor="Black" style="left: 63px; position: absolute; top: 202px">
<Columns>
<asp:BoundField DataField="text_course" HeaderText="Course Name" SortExpression="text_course" />
<asp:BoundField DataField="text_course_id" HeaderText="Course ID" SortExpression="text_course_id" />
<asp:CommandField ShowSelectButton="True" />
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<RowStyle BackColor="White" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
</asp:GridView>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSourcetest"
DataTextField="text_course" DataValueField="text_course" Style="left: 206px;
position: absolute; top: 159px" Font-Size="Medium" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" AutoPostBack="True">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSourcetest" runat="server" ConnectionString="Data Source=PRIVATE-DE89F9E;Initial Catalog=Con+Porject;Integrated Security=True"
ProviderName="System.Data.SqlClient" SelectCommand="SELECT [text_course] FROM [Text]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"></asp:SqlDataSource>
<BUTTON onclick="ButtonClick()" style="left: 76px; position: absolute; top: 91px">Click Me!</BUTTON>
<input id="Hidden1" type="hidden" runat="server" />
<asp:HiddenField ID="HiddenField1" runat="server" />
<asp:Label ID="Label1" runat="server" Text="sdf"></asp:Label>
</form>
</BODY>
</HTML>
vb.net .NET ASP.NET
vivek_iit
All-Star
17778 Points
3189 Posts
MVP
Re: Hidden View Data
Jun 12, 2007 04:42 AM|LINK
Where are you capturing the value from the hidden field? Please paste that code as I am unable to find it in the code you pasted.
-Vivek
Communifire: Social Networking and Business Collaboration Platform