|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
passing variable to sql statement in asp.net 2.0?other things with no success. Any help would be greatly appreciated. Thanks. <body> <form id="form1" runat="server"> <% '' get user login info and strip domain name.... Dim X As Object, strCompletePath As String, getUser As String strCompletePath = Request.ServerVariables("LOGON_USER") X = Split(strCompletePath, "\") getUser = X(UBound(X)) strFileName.Text = getUser %> <asp:TextBox ID="strFileName" runat="server" MaxLength="1000"></asp:TextBox> <br /> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Alias" DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display." CellPadding="4" ForeColor="#333333" GridLines="None"> <Columns> <asp:BoundField DataField="Alias" HeaderText="Alias" ReadOnly="True" SortExpression="Alias" /> <asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" /> <asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" /> <asp:BoundField DataField="Active" HeaderText="Active" SortExpression="Active" /> </Columns> <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> <EditRowStyle BackColor="#999999" /> <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /> <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:USTools_DevConnectionString1 %>" ProviderName="<%$ ConnectionStrings:USTools_DevConnectionString1.ProviderName %>" SelectCommand="SELECT * FROM [User] WHERE [Alias] LIKE '<%=getUser%>' " OldValuesParameterFormatString=""> <%-- <InsertParameters> <asp:ControlParameter ControlID="strFileName" DefaultValue="0" Name="getUser" PropertyName="Text" Direction="Input" ConvertEmptyStringToNull="true" Size="1000" /> </InsertParameters>--%> </asp:SqlDataSource> </form> </body> hi, since you are already using a ControlParameter, pass that instead of
trying to use inline code blocks inside your SelectCommand. So instead of <%=getUser%> supply instead just @getUser. Readup more on the ControlParameter here : http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.controlparameter.aspx Regards, Alessandro Zifiglio http://www.AsyncUI.net Show quoteHide quote "billb" <bkbez***@aimcomm.com> ha scritto nel messaggio news:uKl26uFpGHA.4236@TK2MSFTNGP03.phx.gbl... > Anyone have any ideas how this works? I've tried old school and a ton of > other things with no success. Any help would be greatly appreciated. > Thanks. > > > > <body> > > <form id="form1" runat="server"> > > <% > > '' get user login info and strip domain name.... > > Dim X As Object, strCompletePath As String, getUser As String > > strCompletePath = Request.ServerVariables("LOGON_USER") > > X = Split(strCompletePath, "\") > > getUser = X(UBound(X)) > > strFileName.Text = getUser > > %> > > <asp:TextBox ID="strFileName" runat="server" > MaxLength="1000"></asp:TextBox> > > <br /> > > <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" > DataKeyNames="Alias" > > DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to > display." CellPadding="4" ForeColor="#333333" GridLines="None"> > > <Columns> > > <asp:BoundField DataField="Alias" HeaderText="Alias" ReadOnly="True" > SortExpression="Alias" /> > > <asp:BoundField DataField="FirstName" HeaderText="FirstName" > SortExpression="FirstName" /> > > <asp:BoundField DataField="LastName" HeaderText="LastName" > SortExpression="LastName" /> > > <asp:BoundField DataField="Active" HeaderText="Active" > SortExpression="Active" /> > > </Columns> > > <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> > > <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> > > <EditRowStyle BackColor="#999999" /> > > <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" > /> > > <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" > /> > > <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> > > <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> > > </asp:GridView> > > <asp:SqlDataSource ID="SqlDataSource1" runat="server" > > ConnectionString="<%$ ConnectionStrings:USTools_DevConnectionString1 %>" > > ProviderName="<%$ > ConnectionStrings:USTools_DevConnectionString1.ProviderName %>" > > SelectCommand="SELECT * FROM [User] WHERE [Alias] LIKE '<%=getUser%>' " > OldValuesParameterFormatString=""> > > <%-- <InsertParameters> > > <asp:ControlParameter > > ControlID="strFileName" > > DefaultValue="0" > > Name="getUser" > > PropertyName="Text" > > Direction="Input" > > ConvertEmptyStringToNull="true" > > Size="1000" > > /> > > </InsertParameters>--%> > > </asp:SqlDataSource> > > </form> > > </body> > >
Dropdown List doesn't know what's in it's list
Repeater and text boxes inside how to change labelvalue when deleting row in gridview? Max Number of Web Controls Per Page??? How to put an image in a GridView textfield not recognized in gridview menu control with XML file creative scroll bar for asp.net Datagrids and User Controls Menu control and hover text color |
|||||||||||||||||||||||