DataSource Controls :: How To Use LoginName As Filter

Jul 8, 2010

I have seen this question asked about a half a million times and I still haven't been able to get my solution working by reading there answers.

First off I am using visual web developer 2008 express. I am brand new to asp.net net so me="nub"

I watched some videos on how to setup a website soloution and I did got a free cs and all that got it working. I installed the Ms Membership for loging in and out of my website. I got all that working. I installed the database for the membership on a sql server followed the video for doing that and everything works.

I then decided to do something so simple. I thought it was so simple.

I created a dropdown list using the control and I wanted it to go out to my database on my sql server and get my account numbers and filter them by using the current membership member that is logged in. I see that I can display my current user like this

<asp:LoginName ID="LoginName1" runat="server" />

I can see my user log in and out of the website and that seems to work fine.

So here is what my current dropdown list looks like I say current because I have tried this a ton of times with different parm options but none work.

[code]....

View 2 Replies


Similar Messages:

DataSource Controls :: Using LoginName As A Search Parameter?

Feb 23, 2010

Im working on my Dissertation and am seriously stuck. Im creating a blogging site with the ability to log in, this will also include the ability to search for projects etc. (created in Visual Studio in VB)

There are different roles: Student, admin, tutor. the table is made up of 2 tables aspnetdb.mdf and blogging.accdb; the first was created by visual studio and the later is mine that contains the projects, bloggs etc.

I want to use the asp:loginName in a search that is sourcing its data from the blogging database, Iv tried for days to do it myself, by trying to write an inner join manually, using its full name etc but keep coming up against a brick wall.

View 1 Replies

DataSource Controls :: Use The LoginName As A Parameter In An SQL Select?

Feb 3, 2010

I need to do to get the LoginName value.

Once I can retrieve it I want to use it as an sql parameter.

I've tried user.identity.name, profile.username and many variations, but they all draw a blank.

View 6 Replies

DataSource Controls :: How To Filter Gridview On Daterange

Oct 20, 2010

I have a gridview, fed from a datasource. Now I need to filter the data based on the values from two textboxes, getting their values from ajax CalendarExtenders.

The original (and working) datasource lookkis like this, just filtering on productnumbers:

[Code]....

Now trying to filter on the dates as well:

[Code]....

Now it goes like this:

I get all records. The productfiltering from the first eaxmple does not do anything anymore (probably related to the next problem)

Entering a date in the textbox (via the calendarextender) and pressing a button to refresh (databind my gridview) throws the following exception:

System.Data.SyntaxErrorException: The expression contains an invalid string constant: '10/01/2010 00:00:00.

Its obviously a type problem, but how do I solve it? Actually i need a daterange (from two textboxes) but simplified it here)

View 3 Replies

DataSource Controls :: Filter Parameters/Search Form

Oct 10, 2010

I've got a gridview that I need to perform filters on. All works great until I try and add a date range..

Below is the code. Basically I have 5 dropdown lists which all filter as expected giving them the option to use each one or just the ones they need.

The problem is they want to also have the option of filtering by date i.e date range or greater than or less than or equal to etc..

As soon as I add the date parameter it stops the other filters working. I'm guessing because I have a null value in the date field (textbox) if they dont use the option??

Does anyone have a sample on how to filter by dropdown lists and dates keeping in mind they wont use all the filter options?

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<style type="text/css">
.style2
{
width: 100%;
}
.style3
{
width: 137px;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
</br>
<table>
<tr>
<td>
Person Responsible</td>
<td>
<asp:DropDownList ID="DDLPersonResponsible" runat="server"
DataSourceID="SqlDataSource2" DataTextField="AssignedTo"
DataValueField="AssignedTo" AppendDataBoundItems="True"
AutoPostBack="True" Height="22px" Width="200px">
<asp:ListItem Text="All" Value="%"></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
Location</td>
<td>
<asp:DropDownList ID="DDlLocation" runat="server" Height="22px" Width="200px"
DataSourceID="SqlDataSource3" DataTextField="location"
DataValueField="location" AppendDataBoundItems="True"
AutoPostBack="True">
<asp:ListItem Text="All" Value="%"></asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>"
SelectCommand="usp_Locations" SelectCommandType="StoredProcedure">
</asp:SqlDataSource>
</td>
</tr>
<tr>
<td>
Activity/Product/Service</td>
<td>
<asp:DropDownList ID="DDlActivity" runat="server" DataSourceID="SqlDataSource4"
DataTextField="Activity" AppendDataBoundItems="True"
AutoPostBack="True" Height="22px" Width="200px">
<asp:ListItem Text="All" Value="%"></asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource4" runat="server"
ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>"
SelectCommand="usp_Activity" SelectCommandType="StoredProcedure">
</asp:SqlDataSource>
</td>
</tr>
<tr>
<td>
Risk Ranking</td>
<td>
<asp:DropDownList ID="DDlRiskRanking" runat="server" AppendDataBoundItems="True"
AutoPostBack="True" >
<asp:ListItem Value="%">All</asp:ListItem>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
Reference</td>
<td>
<asp:DropDownList ID="DDLReference" runat="server" DataSourceID="SqlDataSource5"
DataTextField="Reference" AppendDataBoundItems="True"
AutoPostBack="True" Height="22px" Width="200px">
<asp:ListItem Text="All" Value="%"></asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource5" runat="server"
ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>"
SelectCommand="usp_SelectReference" SelectCommandType="StoredProcedure">
</asp:SqlDataSource>
</td>
</tr>
<tr>
<td>
Target Date</td>
<td style="margin-left: 40px">Greater than
<asp:TextBox ID="txtstartTargetDate" runat="server" AutoPostBack="True"></asp:TextBox> Less Than
<asp:TextBox ID="txtendTargetDate" runat="server" AutoPostBack="True"></asp:TextBox>
</td>
</tr>
</table>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>"
SelectCommand="usp_AssignOwner" SelectCommandType="StoredProcedure">
</asp:SqlDataSource>
<br />
<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="IssueId"
DataSourceID="SqlDataSource1" Width="803px" CellPadding="4"
ForeColor="#333333"
EmptyDataText="There are no matching records to display.">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="IssueId" HeaderText="IssueId" InsertVisible="False"
ReadOnly="True" SortExpression="IssueId" />
<asp:BoundField DataField="BriefDescription" HeaderText="BriefDescription"
SortExpression="BriefDescription" />
<asp:BoundField DataField="DateEntered" HeaderText="DateEntered"
SortExpression="DateEntered" />
<asp:BoundField DataField="EnteredBy" HeaderText="EnteredBy"
SortExpression="EnteredBy" />
<asp:BoundField DataField="Likelihood" HeaderText="Likelihood"
SortExpression="Likelihood" />
<asp:BoundField DataField="Consequence" HeaderText="Consequence"
SortExpression="Consequence" />
<asp:BoundField DataField="Location" HeaderText="Location"
SortExpression="Location" />
<asp:BoundField DataField="Activity" HeaderText="ActivityProductService"
SortExpression="Activity" />
<asp:BoundField DataField="Scope" HeaderText="Scope"
SortExpression="Scope" />
<asp:BoundField DataField="Aspect"
HeaderText="Aspect" SortExpression="Aspect" />
<asp:BoundField DataField="AspectRevised" HeaderText="AspectRevised"
SortExpression="AspectRevised" />
<asp:BoundField DataField="Impact" HeaderText="Impact"
SortExpression="Impact" />
<asp:BoundField DataField="Objective" HeaderText="Objective"
SortExpression="Objective" />
<asp:BoundField DataField="KeyAction" HeaderText="KeyAction"
SortExpression="KeyAction" />
<asp:BoundField DataField="TargetDate" HeaderText="TargetDate"
SortExpression="TargetDate" />
<asp:BoundField DataField="PersonResponsible" HeaderText="PersonResponsible"
SortExpression="PersonResponsible" />
<asp:BoundField DataField="PercentageCompleted"
HeaderText="PercentageCompleted" SortExpression="PercentageCompleted" />
<asp:BoundField DataField="Reference" HeaderText="Reference"
SortExpression="Reference" />
<asp:BoundField DataField="Comments" HeaderText="Comments"
SortExpression="Comments" />
<asp:BoundField DataField="Status" HeaderText="Status"
SortExpression="Status" />
<asp:BoundField DataField="AssignedTo" HeaderText="AssignedTo"
SortExpression="AssignedTo" />
<asp:BoundField DataField="RiskRanking" HeaderText="Risk Ranking" />
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>"
SelectCommand="usp_AllIssues" SelectCommandType="StoredProcedure" FilterExpression="assignedto like '{0}' and location like '{1}' and activity like '{2}' and riskranking like '{3}' and reference like '{4}' and targetdate > '{5}'">
<FilterParameters>
<asp:ControlParameter Name="assignedto" ControlID="ddlpersonresponsible"
PropertyName="SelectedValue" />
<asp:ControlParameter Name="location" ControlID="ddllocation"
PropertyName="SelectedValue" />
<asp:ControlParameter Name="activity" ControlID="ddlactivity"
PropertyName="SelectedValue" />
<asp:ControlParameter Name="riskranking" ControlID="ddlriskranking"
PropertyName="SelectedValue" />
<asp:ControlParameter Name="Reference" ControlID="ddlreference"
PropertyName="SelectedValue" />
<asp:ControlParameter Name="startdate" ControlID="txtStartTargetDate"
PropertyName="text" />
</FilterParameters>
</asp:SqlDataSource>
</asp:Content>

View 2 Replies

DataSource Controls :: Trying To Filter Out Data That Is Being Pulled From Sql Table

May 17, 2010

I have a form that has dropdown box and user can either select Store Associate or Store Manager, when they click on either, I have GetASsociate function that pulls data from sql database. What i am trying to figure out how to do, is that if they say select Store Manager I want to filter what data to pull from that sql table that has all associates in it, so I was trying use an 'expression' statement to stay if Store Manager was selected, only pull me back the store managers from that table. Then same thing for if they selected STore Assoicate, then only bring me back teh store assocites from that table. But the expression statment does not appear to be working.

asxc.vb code behind
Private
Sub GetDataAssociates()Dim provider
As DbDataProvider' Create a collection of parameters.
Dim coll
As
New DbParameterCollection()
Dim prmCompany
As
New DbParameter
provider = DbDataProviderFactory.GetProvider(DataAccessLayer.Enumerations.ProviderType.SqlClient,
"GetAssociatesByCompany")
prmCompany.ParameterName = "@Company"
prmCompany.DbType = DbType.Int32
Select
Case ddlCompany.SelectedItem.Text.ToStringCase
"Stores"
prmCompany.Value = 100
Case
"Corporate"
prmCompany.Value = 300
Case
"Executives"
prmCompany.Value = 900
Case
"Union"
prmCompany.Value = 200
Case
Else
prmCompany.Value = 0
End
Select
coll.Add(prmCompany.ParameterName, prmCompany)
Select
Case
Me.ddlOrganisationStructure.SelectedValue.Trim
Case
"StoreManagers"
Dim expression
As
String
expression =
"Pos_Group >'0900'"
dsAssociates.Merge(provider.GetData(coll).Tables(0).Select(expression)) --IS ERRORING OUT ON ME HERE AT THIS LINE
dsAssociates.Merge(provider.GetData(coll))
dtAssociates = dsAssociates.Tables(0)
Case
"StoreAssociates"
Dim expression
As
String
expression =
"pos_group < '0900'
dsAssociates.Merge(provider.GetData(coll).Tables(0).Select(expression)) -IS ERRORING OUT ON ME HERE AT THIS LINE
dtAssociates = dsAssociates.Tables(0)
End
Select

View 4 Replies

DataSource Controls :: Filtering GridView With Filter Parameters?

May 3, 2010

I have this GridView with this member details:

Members (ID, Title, Forename, Surname)

I want to use Drop Down List to Filter Members table by MemberType, this means having to Join the following three Tables..

Members (ID, Title, Forename, Surname, Memb_ProdID*) has Foreign Key for MemberProducts Table

MemberType (ID, MembType)

MemberProducts (ID, Duration, Price, Terms, memb_TypeID*) has Foreign Key for memberType table MembType is in Italic and underlined, how do I use this to filter members details in GridView.

View 4 Replies

DataSource Controls :: Use A DataViewManager To Filter Data In A Dataset?

Feb 9, 2010

I try to use a DataViewManager to filter data in a dataset, but somehow it does not work. The code below produces the error "A field or property with the name '< any field>' was not found on the selected data source". However, when I replace "GridView1.DataSource = dvm" with "GridView1.DataSource = ds" it works.

[Code]....

View 5 Replies

DataSource Controls :: Why Can't Write A Sql Filter By Chinese Character

Feb 4, 2010

why i can't write a sql filter by chinese character like the following select name from ABC where name like ' %可%'

View 1 Replies

DataSource Controls :: Filter SqlDataSource With Boolean Values?

Feb 17, 2011

I have an SqlDataSource, which is filtered by two RadioButtonLists. The markup is as follows:

[Code]....

In my code-behind I add the filterexpression when the radiobuttonlists are changed

[Code]....

My problem is that while it works fine when changing the RadioButtonListProducts the filtering works nicely, there is a problem with the RadioButtonListStatus, that filters on the Boolean column, 'Godkendt'. It works nicely if its set to 'Alle' (No filtering on that parameter) but when set to anything else, no records are shown. I suppose the problem is in the filterexpression

[Code]....

View 1 Replies

DataSource Controls :: Writing A Query Filter That Gets All Results For That Day?

May 11, 2010

i have a "Users today" function that i am trying to work on, i have all the tables set up, and a TimeStamp column, i would like to know how i could get all the users that appeared, but for that day only.

So i used the select statement, but then when i tried to add into query, filtering, i tried using the DateTime.Now, but it only got the users specific to that date, hour, and second.

View 3 Replies

DataSource Controls :: How To To Filter A Datetime Field For A Date Without The Time

May 16, 2010

I want to filter a datetime field for a date without the time...

I want all fields that contain the selected date regardless of the time.

What should I use as the filter expression?

View 2 Replies

DataSource Controls :: How To Filter Dataset/datatable Depending On The Values

Apr 7, 2010

i have a dataset which contains some data.

let dataset have some columns one among them is " Type "

let the values in column type be type1,type2.type3 and so on

now if i want to filter dataset which contains only type3

View 4 Replies

DataSource Controls :: Filter SQL Queries Based On The Store ID Associated With A User ID?

Jan 16, 2010

I am planning a project for a pharmacy to enter quality control data to generate reports and graphs with Crystal Reports. There are 20 stores, I need to password protect the entrance page, giving each store their own username and password (just one per store is fine), allowing the store to only access that store's data. Each store will have an associated ID in the MSSQL table.I am using the Membership Provider. I know I need to implement user roles for Managers and Stores levels (Managers can run reports for all stores), I wonder if I can set the default store ID for insert/edit templates after that specific store logs in.Basically, I think I need to filter SQL queries based on the store ID associated with a user ID. I have seen a .NET site that, after logging in, you type in a store id into a textbox, and it gives you access only to that stores data. Something like this would work for my situation.Can anyone explain or show me an example for the best method to accomplish this with C#?

View 2 Replies

DataSource Controls :: Trying To Filter The Employees Using A List Of Strings Which Match With The Employee.Name?

Mar 2, 2010

i have an List<String> lstrings which contains a list of strings. If i want to write a linq query on a list<Employees> employees to filter for employees.name in {lstrings} var lquery = (from e in employees where e.Title =="ASP.NET" && e.Name.Contains(lstrings) select e); Im trying to filter the employees using a list of strings which match with the employee.Name

View 5 Replies

DataSource Controls :: Filter - Select Date In Ddl And Use Selectedvalue In Gridview SelectCommand

Nov 7, 2010

I've got a gridview which works fine. I use dropdownlists which are filled with distinct values of the columns. So when I select an item in a drompdownlist the gridview refreshes based on the selected value. When I have a column which uses string values, I can start the filter with a default % value to use in my select paramaters. But when I have a date column, I can't use that. I use a datasource for the gridview and I prefer to leave codebehind out if this is not needed. Now I use >= in my gridview select to show all rows. but I want to use only = to make the filter work correct when I select a date in the ddl and use the selectedvalue in the gridview selectCommand

<asp:DropDownList ID="ddlUpdateDatum" DataSourceID="dsPopulateUpdateDatum"
AutoPostBack="true" DataValueField="UPDATEDATE" runat="server"
CssClass="selectinput" AppendDataBoundItems="true">
<asp:ListItem Text="All" Value="01/01/1900"></asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="dsPopulateUpdateDatum" runat="server"
ConnectionString="<%&#36; ConnectionStrings:GAMSYSTEMSqlServer %>"
SelectCommand="SELECT DISTINCT(UPDATEDATE) FROM [messages] ORDER BY UPDATEDATE ASC ">
</asp:SqlDataSource>
And I use this in the gridview datasource:
<asp:SqlDataSource
runat="server"
ID="dsGridview"
ConnectionString="<%&#36; ConnectionStrings:DBSqlServer %>"
SelectCommand = "SELECT * FROM [messages] WHERE AND UpdateDatum >= @UpdateDatePar ORDER BY UpdateDatumDESC"
>
<SelectParameters>
<asp:ControlParameter Name="UpdateDatePar" ControlID="ddlUpdateDate" PropertyName="SelectedValue" Type="string" />
</SelectParameters>

View 2 Replies

DataSource Controls :: Filter A DataView To Return All The Rows Whose Column X Starts With A Number

Jan 29, 2010

I'm trying to filter a DataView to return all the rows whose column x starts with a number: The following works in SQL Server:

select *
from dbo.Page
where Name like '[0-9]%'

However, when I try this:

dataView = new DataView( someDataTable, "Name LIKE '[0-9]%'", "Name ASC", DataViewRowState.CurrentRows);

I get "invalid parameter [0-9] with Operator Like" error message. What is the correct syntax to achieve my goal?

View 7 Replies

Data Controls :: Use TextBox To Search And Filter GridView Populated From Code Behind DataSource

May 7, 2015

[URL] .... I Need to search record from GridView by using the textbox but not want to configure this with SQLDataSource Manually (Front End) therefore how to filter gridview from Codebehind. 

View 1 Replies

Forms Data Controls :: Provide The Filter Functionality To Gridview Like The Excel Filter?

Oct 31, 2010

I need good css for Gridview just like the mac css

can we provide the filter functionality to gridview like the excel filter.

View 3 Replies

Forms Data Controls :: Auto Populate Formview Fields From Calendar And LoginName?

Apr 12, 2010

I am inserting 4 fields into a table trought an SqlDataSource and a FormView element. These fields are ID (autopopulated), date(selected from calendar and/or todays date as default), Company name(user input), and UserID (taken from LoginName?).

I am able to inser the data in to the table when typing it, but I would like to have the UserID fiel auto completed and the date as well, or filled with the selected calendar date.

This is my part of my code.-------------------------------------------

[Code]....

View 3 Replies

DataSource Controls :: Trying To Place A Filter By "MONTH(irActivity.ActivityDate) = 1)"

May 24, 2010

I'm trying to count the number of activities in a month without using the Case When clause

This is what I was able to produce so far

SELECT COUNT(MONTH(irActivity.ActivityDate)) AS 'JAN'

FROM irActivity INNER JOIN pdEmployee ON irActivity.Act = pdEmployee.Act

ORDER BY 'JAN'

I'm trying to place a filter by "MONTH(irActivity.ActivityDate) = 1)"

Which then gives me a syntax error

View 6 Replies

MVC :: Securing Actions/controllers - Create A Custom Filter Or Use Built-in Filter?

Jan 1, 2010

In securing actions/controllers, do I have to create a custom filter or use MVC built-in filter?

To use the built-in attribute Authorize() on an action/controller or create a separate class that inherits the ActionFilterAttribute which has a method (OnActionExecuting) to override and do the authentication there?

View 2 Replies

Active Directory/LDAP :: Nested Groups Filter/create A Filter Which Will Return All The Users Which Belong To One Of The "kuku"s Group?

Mar 9, 2010

In my organization we use nested groups. For a particular usage, we have a group (let's assume that the group name "kuku"), and the names of all the nested groups under it contains "kuku" as well.

We may assume that no other group in the LDAP has "kuku" in the name.

I need to create a filter which will return all the users which belong to one of the "kuku"s group.

Obviously, using this filter will bring only the head kukus

(&(&(objectclass=user)(objectclass=person))(memberOf=CN=kuku,cn=...rest of the group DN...))

How can I use wild card to fetch all users which belong to any kuku?

For example: (&(&(objectclass=user)(objectclass=person))(memberOf=CN=.*kuku.*))

View 1 Replies

C# - Run Both Authorize Filter And Action Filter On Unauthenticated MVC Request

Mar 17, 2010

I have decorated my base controller with a couple of action filters. They work fine.

One of those filters sets up the request - does things like set the culture based on the domain, etc.

I also have a handful of actions that require authorization using the Authorize attribute.

My problem is that when an user attempts to request a page they are not authorized to access, the authorization filter kicks in and redirects them to a page telling them that they cannot vie the page.

The issue is that the action filters never run so the culture and other request data is never set. This effectively causes language to be wrong in the view and other data to be missing.

I know that authorization filters run first but my question is this: How can I design this such that I can ensure that certain methods are always run before the view is returned, regardless of the authorization.

View 1 Replies

Storing The LoginName In A Variable

Aug 13, 2010

I have a LoginName1, LoginView and Login Status on my Master Page. Whenever a user logs himself in, the LoginName1 displays (as for example):

Welcome omarakhtar

Now the only thing I want is how to store this omarakhtar into some variable? Kindly, let me know.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved