M
Mike M
Hello All, I am an asp coder trying to do .net. I think i have a
simple problem, but I cannot find a solution to this anywhere. Here
is what I have.
I have one aspx page with a multiview that contains 2 views. View1
has 3 text boxes that a user can enter search parameters. View2 has a
gridview with a sqldatasource bound to it to display the results. I
cannot figure out how to execute the sql statement so it will populate
the gridview. Here is my code:
aspx Page:
<%@ Page Language="VB" MasterPageFile="~/MPMain.master"
AutoEventWireup="false" CodeFile="SecuritySearch.aspx.vb"
Inherits="Admin_SecuritySearch" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
Security Search
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2"
Runat="Server">
<asp:MultiView ID="MultiView1" runat="server">
<asp:View ID="View1" runat="server">
<table style="width: 70%">
<tr>
<td colspan="2">
<asp:Label ID="lblMessage" runat="server" Font-
Bold="True" Font-Names="Arial" Font-Size="10pt"
ForeColor="Red" Text="Label"></asp:Label></
td>
</tr>
<tr>
<td align="right">
First Name:</td>
<td align="left">
<asp:TextBox ID="txtFirstName"
runat="server"></asp:TextBox></td>
</tr>
<tr>
<td align="right">
Last Name:</td>
<td align="left">
<asp:TextBox ID="txtLastName" runat="server"></
asp:TextBox></td>
</tr>
<tr>
<td align="right">
Alias:</td>
<td align="left">
<asp:TextBox ID="txtAlias" runat="server"></
asp:TextBox></td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<br />
<asp:Button ID="btnSearch" runat="server"
Text="Search" /></td>
</tr>
</table>
</asp:View>
<asp:View ID="View2" runat="server">
View 2<br />
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="FULL_NAME_SFI"
HeaderText="FULL_NAME_SFI" SortExpression="FULL_NAME_SFI" />
<asp:BoundField DataField="JOBTITLE"
HeaderText="JOBTITLE" SortExpression="JOBTITLE" />
<asp:BoundField DataField="DEPARTMENT_NAM_SFI"
HeaderText="DEPARTMENT_NAM_SFI" SortExpression="DEPARTMENT_NAM_SFI" />
<asp:BoundField DataField="EMAIL_ALIAS_SFI"
HeaderText="EMAIL_ALIAS_SFI" SortExpression="EMAIL_ALIAS_SFI" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:EUCNET00005 %>"
SelectCommand="SELECT [FULL_NAME_SFI], [JOBTITLE],
[DEPARTMENT_NAM_SFI], [EMAIL_ALIAS_SFI]
FROM [0002_SFVW]
WHERE (([EMAIL_ALIAS_SFI] = @EMAIL_ALIAS_SFI)
or
(([FIRST_NAME] LIKE '%' + @FIRST_NAME + '%')
AND ([LAST_NAME] LIKE '%' + @LAST_NAME + '%')))
ORDER BY [FIRST_NAME], [LAST_NAME]">
<SelectParameters>
<asp:ControlParameter ControlID="txtAlias"
Name="EMAIL_ALIAS_SFI" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="txtFirstName"
DefaultValue=" " Name="FIRST_NAME"
PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="txtLastName"
Name="LAST_NAME" PropertyName="Text"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</asp:View>
</asp:MultiView>
</asp:Content>
Code Behind:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Me.MultiView1.ActiveViewIndex = 0
End Sub
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSearch.Click
Me.MultiView1.ActiveViewIndex = 1
Me.GridView1.DataBind()
End Sub
simple problem, but I cannot find a solution to this anywhere. Here
is what I have.
I have one aspx page with a multiview that contains 2 views. View1
has 3 text boxes that a user can enter search parameters. View2 has a
gridview with a sqldatasource bound to it to display the results. I
cannot figure out how to execute the sql statement so it will populate
the gridview. Here is my code:
aspx Page:
<%@ Page Language="VB" MasterPageFile="~/MPMain.master"
AutoEventWireup="false" CodeFile="SecuritySearch.aspx.vb"
Inherits="Admin_SecuritySearch" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
Security Search
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2"
Runat="Server">
<asp:MultiView ID="MultiView1" runat="server">
<asp:View ID="View1" runat="server">
<table style="width: 70%">
<tr>
<td colspan="2">
<asp:Label ID="lblMessage" runat="server" Font-
Bold="True" Font-Names="Arial" Font-Size="10pt"
ForeColor="Red" Text="Label"></asp:Label></
td>
</tr>
<tr>
<td align="right">
First Name:</td>
<td align="left">
<asp:TextBox ID="txtFirstName"
runat="server"></asp:TextBox></td>
</tr>
<tr>
<td align="right">
Last Name:</td>
<td align="left">
<asp:TextBox ID="txtLastName" runat="server"></
asp:TextBox></td>
</tr>
<tr>
<td align="right">
Alias:</td>
<td align="left">
<asp:TextBox ID="txtAlias" runat="server"></
asp:TextBox></td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<br />
<asp:Button ID="btnSearch" runat="server"
Text="Search" /></td>
</tr>
</table>
</asp:View>
<asp:View ID="View2" runat="server">
View 2<br />
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="FULL_NAME_SFI"
HeaderText="FULL_NAME_SFI" SortExpression="FULL_NAME_SFI" />
<asp:BoundField DataField="JOBTITLE"
HeaderText="JOBTITLE" SortExpression="JOBTITLE" />
<asp:BoundField DataField="DEPARTMENT_NAM_SFI"
HeaderText="DEPARTMENT_NAM_SFI" SortExpression="DEPARTMENT_NAM_SFI" />
<asp:BoundField DataField="EMAIL_ALIAS_SFI"
HeaderText="EMAIL_ALIAS_SFI" SortExpression="EMAIL_ALIAS_SFI" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:EUCNET00005 %>"
SelectCommand="SELECT [FULL_NAME_SFI], [JOBTITLE],
[DEPARTMENT_NAM_SFI], [EMAIL_ALIAS_SFI]
FROM [0002_SFVW]
WHERE (([EMAIL_ALIAS_SFI] = @EMAIL_ALIAS_SFI)
or
(([FIRST_NAME] LIKE '%' + @FIRST_NAME + '%')
AND ([LAST_NAME] LIKE '%' + @LAST_NAME + '%')))
ORDER BY [FIRST_NAME], [LAST_NAME]">
<SelectParameters>
<asp:ControlParameter ControlID="txtAlias"
Name="EMAIL_ALIAS_SFI" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="txtFirstName"
DefaultValue=" " Name="FIRST_NAME"
PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="txtLastName"
Name="LAST_NAME" PropertyName="Text"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</asp:View>
</asp:MultiView>
</asp:Content>
Code Behind:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Me.MultiView1.ActiveViewIndex = 0
End Sub
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSearch.Click
Me.MultiView1.ActiveViewIndex = 1
Me.GridView1.DataBind()
End Sub