Label Showing User.identity.name In Detailsview

Aug 30, 2007

Hi, any suggestions on why my label doesn't show the current user.identity.name when used in a detailsview (header-field or insert-field), when it works just fine placed directly on my page ?

Please help ! (I want to bind myLabelX.Text to a db-table, but it contains no value..)

codebehind  : 1 using System;
2 using System.Data;
3 using System.Configuration;
4 using System.Collections;
5 using System.Web;
6 using System.Web.Security;
7 using System.Web.UI;
8 using System.Web.UI.WebControls;
9 using System.Web.UI.WebControls.WebParts;
10 using System.Web.UI.HtmlControls;
11
12
13 public partial class Test_2 : System.Web.UI.Page
14 {
15
16 protected void Page_Load(object sender, EventArgs e)
17 {
18 if ((!IsPostBack)) myLabelX.Text = User.Identity.Name;
19 }
20
21 }
 

View 3 Replies


ADVERTISEMENT

SQL Data Not Showing In Label

Mar 13, 2008

Here is my code.  Basically what I am doing is selecting from the database based on the current user.   The ReaderResults.Text label is not showing the info pulled from the database, and the ReaderError.Text label is not showing an error.  I also tried putting the ReaderResults.Text label inside the loop and that didnt work. Any suggestions?
'Database ConnectionDim con As New SqlConnection("Data Source = .SQLExpress;integrated security=true;attachdbfilename=|DataDirectory|ASPNETDB.mdf;user instance=true")Dim currentUserID
currentUserID = Context.User.Identity.Name.ToString()
Label1.Text = currentUserID
Dim selectSQL As String
selectSQL = "SELECT companyKey FROM Company WHERE UserID = ('" + currentUserID + "')"Dim cmd2 As New SqlCommand(selectSQL, con)
Dim reader As SqlDataReaderDim CompanyKey
Try
con.Open()
reader = cmd2.ExecuteReader()Do While reader.Read()
CompanyKey = reader("CompanyKey").ToString()
Loop
reader.Close()Catch err As Exception
ReaderError.Text = "Error selecting record."
ReaderError.Text &= err.Message
ReaderResults.Text = CompanyKey
Finally
con.Close()
End Try

View 1 Replies View Related

SQL Data Not Showing Up In My Label

Mar 13, 2008

The ReaderResults.Text is not returning a value.  I am not sure what is going on because the table and all columns are full, Label1.Text shows the current username of the user loggedon, and no error is showing up in ReaderError.Text.  Anyone have any ideas?
 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Database ConnectionDim con As New SqlConnection("Data Source = .SQLExpress;integrated security=true;attachdbfilename=|DataDirectory|ASPNETDB.mdf;user instance=true")
'Job1 InfoDim currentUserID
currentUserID = Context.User.Identity.Name.ToString()
Label1.Text = currentUserID
Dim selectSQL1 As String
selectSQL1 = "SELECT companyKey FROM Company WHERE UserID = ('" + currentUserID + "')"Dim cmd1 As New SqlCommand(selectSQL1, con)
Dim reader As SqlDataReaderDim CompanyKey
'Job1 Select
Try
con.Open()
reader = cmd1.ExecuteReader()Do While reader.Read()
CompanyKey = reader("CompanyKey").ToString()
Loop
reader.Close()Catch err As Exception
ReaderError.Text = "Error selecting record."
ReaderError.Text &= err.Message
ReaderResults.Text = CompanyKey
Finally
con.Close()
End Try

View 3 Replies View Related

Login Failed For User 'NT AUTHORITYANONYMOUS LOGON' (but User.identity.name Is Correct)

May 1, 2007

I need help.  The security principal is the correct DomainUser, but the error message says I am not authenticated.
So here is my error Message:
Login failed for user 'NT AUTHORITYANONYMOUS LOGON'. Me.User.Identity.Name=CompanyDomainRyan; System.Security.Principal.WindowsIdentity.GetCurrent=CompanyDomainRyan; HttpContext.Current.User.Identity.Name=CompanyRyan
Generated by:
Dim secPrinc As System.Security.Principal.WindowsIdentity = System.Security.Principal.WindowsIdentity.GetCurrent
Me.lblError.Text = ex.Message & vbCrLf & vbCrLf & "Me.User.Identity.Name=" & Me.User.Identity.Name & "; System.Security.Principal.WindowsIdentity.GetCurrent=" & secPrinc.Name & "; HttpContext.Current.User.Identity.Name=" & HttpContext.Current.User.Identity.Name
Here is the Connection String:
Private ConnString As String = "Server=10.144.162.111;Database=DNS;Trusted_Connection=True"
 
IIS has 4 websites hosted on it.  The parent level allows anonymous with windows auth off, but the website level has anonymous off with widnows auth and digest.
In IIS, is there a problem with having the parent level anonymous and website level windows auth?

View 1 Replies View Related

SQL Server 2008 :: Why User Hostnames Showing As Various

May 6, 2015

Several apps connecting to a SQL 2008 server show the users having a hostname of "Various" when doing an sp_who2 or looking at relevant DMVs.

I joined dm_exec_sessions to dm_exec_connections and was able to get the IP addresses and they resolve back to real clients. So why they'e not displayed and I see "Various" instead?

View 0 Replies View Related

Showing Data Based On The User Logged In.

Feb 25, 2008

Assume I have a heirarchy like the following:

- John Smith

- James Jones
- Robert Allen

- Lisa Andrews
- Bob Thompson

Now, I have a report where whoever is logged in will only see data for themselves and those below them, so John Smith would see everyone including himself, but Lisa Andres would only see herself and Bob Thompson. James Jones would be able to see everyone except John Smith.

How do I go about implementing this code, for example in an asp.net page where one of the user's logs on to view the report. Currently, there is a T-SQL function that creates a user heirarchy table, but it is very slow and I am curious if SSRS 2005 has any new capabilities in handling this.

Thanks,
Saied

View 3 Replies View Related

Get User Identity With Sp ??

Dec 3, 2005

Hi,
Is there a way to get name of user in WinNT (or server logged name) with stored procedure?

I just want to create trigger that will indentify user who created row.

Thanx

View 1 Replies View Related

Add Identity Increment Per User

Sep 11, 2007

HiI have a Jobs Table: Job_ID,User_ID,Job_Info,...Job_ID is the Primary Key.I want to add [Job_ID_PerUser] so I wiil get:Job_ID Job_ID_PerUser User_ID1 1 A2 1 B3 1 C4 2 A5 3 A6 2 CThanks

View 4 Replies View Related

User.Identity.Name Parameters

Dec 3, 2007

 Hi,I have an on screen control to select data from a table. Here are the parameters for the select:           <asp:Parameter DefaultValue="bezlan" Name="recievername" />
            <asp:Parameter DefaultValue="bezlan" Name="recieversname" />this works perfectly if I sign in as bezlan           <asp:Parameter DefaultValue="User.Identity.Name" Name="recievername" />
            <asp:Parameter DefaultValue="User.Identity.Name" Name="recieversname" /> this doesnt pick up any data at all if I sign in as bezlan.Why is this? Is there a special bit of code I need for parameters?Thanks,Jon 

View 6 Replies View Related

How To Ref User.Identity.Name In TSQL

May 16, 2008

Hello everyone,
In SQL Query I need to update a field to my ASP.NET app which has a variable User.Identity.Name() where it contains the Form Authentication of current logon user, SQL has the suser_name() function but this is not what I needed because it returns the user accessing the Database. 
UPDATE [tblData] SET [UserUpdated] = User.Identity.Name()   <= this failed because SQL doesn't recordnize the User.Identity.Name() function.  Is there any method I can use to achieve this?
Thanks in advance. 
 
 
 

View 2 Replies View Related

Question With SQLDATASOURCE And User.identity.name

Feb 20, 2007

is there a way that I can use the sqldatasource with a form view where my sqldatasource select statement is like this
select * from tblUsers where vcUserName=@vcUserName
<selectparameters>
<asp:Parameter Name="user.identity.name" Type="String />
</selectParameters>

View 1 Replies View Related

Filter By Page.User.Identity.Name

Jun 29, 2007

Hiy all,
I have used the code below to capture the current logged in user into my LoginID Filed in my SQL DB.
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load        SqlDataSource1.InsertParameters("LoginID").DefaultValue = Page.User.Identity.Name
 End Sub
Now that I have this in my DB I want to create a Gridview that will filter by this LoginID.
So I want to filter all records where LoginID = the currenlty logged in user ie: filter using Page.User.Identity.Name
So in my SQL code I have WHERE loginID = @Currentuser.
VWD now wants me to define a parameter for this Varaibale @Currentuser... So I want to set this to Page.User.Identity.Name.
My Problem is that in the datasource define parameter area I'm not sure what to define this as.
ie: is Page.User.Identity.Name a cookie , control , Query String , session ?
can someone point me in the right direction to what syntax to use?
Ray..

View 7 Replies View Related

Problem With Identity User In A Report

Apr 4, 2007

Hi,



I use forms authentication with my Report manager. The problem is that I can't display the same information to all the users into the report. For example, in my report, i have one dataset that give me a list of all the store of a compagny. And i have to display only the store onto the user is working. If the user is a boss, he can see the information of all the stores. So i have to know in my report what is the login he uses in the form authetication and i don't know how to do.



Excuse me for my bad english and thank you.



Regards,

Shaouk.

View 3 Replies View Related

Checking Last User Identity On Remote Server

Oct 12, 2006

Is it possible to get the latest inserted Identity value on a remote server?

(The following gives a NULL result:

select ident_current('[my_linked_server].thedatabase.dbo.thetable')

)

View 4 Replies View Related

HttpContext.Current.User.Identity.Name Blank ?

Mar 2, 2007

I have implemented the forms authentication method using  MSDN web site http://msdn2.microsoft.com/en-us/library/ms160724.aspx

and now i want to modify that code

so when i used

Dim UserName as string =HttpContext.Current.User.Identity.Name

from the vb.net code behind

it gives me ss as blank value ?

but the same code i used from the normal web site its gives me the

"SER1Administrator" value for that string(current user)

so my problem is why is that code not working for the report server sample project ,which microsoft provided ?

do i have to change any configuration settings ?

please help me .......i am in trouble ?

(what i really want is i need to get the username from the active page directory? wheather this username exist from the active page directory.)

 

regards

sujithf

 

 

View 1 Replies View Related

HttpContext.Current.User.Identity.Name Form SQLDataSource

Apr 21, 2007

Hi,How do I get hold of the HttpContext.Current.User.Identity.Name from within an sqldatasource? I want to create a WHERE clause that says WHERE UserName = @UserName and the @UserName parameter be filled with the current user name. I would be able to do this in code, but I don't know how to get at this information from within a datasource. At a guess I tried to use the Cookie option from the drop down list, and use the name of the FormsAuthentication Cookie, but this didn't work. Is there a way I can do this? If so how? I don't want to resort to using a hidden field or anything like that if I can help it. Many thanks, Steve 

View 2 Replies View Related

Gridview Select Statement With User.identity.name In The Where Clause

May 5, 2008

Hello everyone,
I have a view, NAS_vPosition that has a coloumn vLogin_Acting and I want to use the user.identity.name to select the row from this table that matches.
So far i have tried:
SelectCommand = "Select * FROM NAS_vPosition WHERE vLogin_Acting = ' <%=User.Identity.Name %> ' "
with no success.
Any help is appreciated

View 6 Replies View Related

Update Detailsview

Dec 18, 2007

Hi,I am using detailsview to update my database and got a question regarding datetime format. Here is part of my code:
<asp:TemplateField HeaderText="Project Deadline">
<EditItemTemplate>
<asp:TextBox ID="txtDeadline_edit" runat="server" Text='<%# Bind("pro_app_deadline") %>'></asp:TextBox>
<asp:CompareValidator ID="txtDeadlineedit_validator" runat="server" ErrorMessage="Not a valid date format" ControlToValidate="txtDeadline_edit" Operator="DataTypeCheck" Type="Date"></asp:CompareValidator>
</EditItemTemplate>
<ItemTemplate><asp:Label ID="txtDeadline" runat="server" Text='<%# Eval("pro_app_deadline") %>'></asp:Label>
</ItemTemplate></asp:TemplateField>
 Since the format of my parameter 'pro_app_deadline' is datetime, it get stored as YYYY-MM-DD hh:mm:ss in datebase. If I want to validate user's input like above way, it always fails since hh:mm:ss append to YYYY-MM-DD. My question is, is there some way I can avoid hh:mm:ss?
Thanks a lot!

View 2 Replies View Related

DetailsView Control (Please Help!!!!)

May 14, 2006

Can someone please tell me what I am doing wrong...
I have a simple webform that has contains a GridView and a DetailsView. Once the GridView is populated the user simply selects a record from the list.  The DetailsView is them populated with all of the data from the selected record.
The DetailsView is bound to a SQL DataSource/CustomerData. I have made sure that the DV control has the Edit/Update Command listed.  The user can click the Edit button and successfully edit the fields but when the user clicks the "Update" button I am getting the following message.
Updating is not supported by data source 'CustomerData' unless UpdateCommand is specified
Why isnt the control handling the Update.
Many Thanks!!!!
T
 
 

View 4 Replies View Related

Select Based On User Identity Name Included In Insert Into Second Table

Aug 25, 2006

I am having issues getting this to work.  I have the user login to a page to
put in a request for vacation.  When they login, I have a label that isn't
visible that is equal to their User.Identity.Name.
I select the user from the employee table where the username = the label User
Identity Name and pull in the emp_id which is the primary key that identifies
the user. 
I need to insert the request into the request table with the emp_id from the
select statement, without showing the em_id on the screen.  I tried using a
hidden field and assigning the emp_id as the value, but it isn't working. 
Not sure if this is the best way to do this.  Really new to ASP.NET 2.0 so I
really appreciate any help.
Thank you!

View 12 Replies View Related

How To Propagate User Identity Form Application Server To Database

Apr 21, 2008

Hi All,

I am new to MS SQL SERVER 2005.
My web application using SQL Server 2005 as back end database to store all the information.
I am using connection pooling to get connection form db.
But my fron end user( user who logged in into webapplication) lost his identity b'coz for database user is application server.
Now I wanna to track front end user in db.

In oracle I can do it by using CLIENT_IDENTIFIER. But in sql server I don't know how to do it.

in oracle i can do it as below
public void setIdentity(Connection conn, String identity) {
PreparedStatement ps;
try {
ps =
conn.prepareCall("begin dbms_session.set_identifier(?); end;");
ps.setString(1, identity);
ps.execute();
ps.close();
} catch (SQLException e) {
// Handle the exception
}
}
<!--[if !supportLineBreakNewLine]-->
once the transaction is complete, the application should reset the identity as follows:

public void clearIdentity(Connection conn) {
PreparedStatement ps;
try {
ps = conn.prepareCall("begin dbms_session.clear_identifier(); end;");
ps.execute();
ps.close();
} catch (SQLException e) {
// Handle the exception
}
}
<!--[if !supportLineBreakNewLine]-->
Please guide me for same.

Thanx in advance.

Bhadu<!--[endif]-->

View 6 Replies View Related

DetailsView Update With Subquery

Jun 9, 2007

Hi everybody,I have a little Problem with an update and Detailsview.I have 2 table (tblUser - uid,uName,rId) and (tblRole - rId, rDescription) In my update I don't want to use the roles id, I want to use the roles Description.Via sql I do a update the role to Admin like that UPDATE tblUser
SET rId =
(SELECT rId
FROM dbo.tblRoles
WHERE (rDescription = 'Admin')) But I don't get it to work for the detailsview update   

View 4 Replies View Related

Problem With UPDATE With Detailsview

Jul 23, 2007

i get  Incorrect syntax near 'nvarchar'.Must declare the scalar variable "@BookingID".



Description: An
unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the
error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near 'nvarchar'.Must declare the scalar variable "@BookingID".

Source Error:





An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.







Stack Trace:




[SqlException (0x80131904): Incorrect syntax near 'nvarchar'.Must declare the scalar variable "@BookingID".] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857354 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734966 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188 ...i am using the Edit feature of the detailsview, seems like the datatype is wrong? ID are int (in my DB, BookingID is int), and also its readonly it should not be updating in the first place right? --------------------------------Any way to debug whats in "new" values? ItemUpdating? how to do it? 

View 3 Replies View Related

Update In DetailsView Not Working

Jun 9, 2008

Hi,
Can anyone tell me why my Update attempts are not working? Here is my code:
<body>
<form id="form1" runat="server">
<div>
 <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px"
AutoGenerateEditButton="True" AutoGenerateRows="False" DataSourceID="SqlDataSource1"
DefaultMode="Edit">
<Fields>
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
</Fields>
</asp:DetailsView><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringListings %>"
SelectCommand="SELECT [City] FROM [Listings]"
UpdateCommand="UPDATE [Listings] Set [City]=@City WHERE [ListingID]=@ListingGuid ">
<UpdateParameters>
<asp:Parameter Name="City" />
<asp:Parameter Name ="ListingGuid" />
</UpdateParameters>
</asp:SqlDataSource>
 
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</div></form>
</body>
And here is my code behindProtected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ListingGuid = Request.QueryString("GUID")
End SubProtected Sub DetailsView1_ItemUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdatedEventArgs) Handles DetailsView1.ItemUpdated
Label1.Text = "updated"
Label2.Text = ListingGuidEnd Sub
Please let me know what I am doing wrong? 
 

View 3 Replies View Related

SqlDataSource && DetailsView UpdateCommand

Mar 6, 2006

Hi
I have a Page with a DetailsView and SqlDataSource. When Editing the DetailsView the Sql;DataSource UpdateCommand does not seem to pick up the @parameters of the form fields. I have used OnItemUpdating to view all Keys/OldValues/NewValues passed into the UpdateCommand but nothing seems to be picked up.
When I place a value into UpdateCommand it updates correctly but does not when I use the form. At this stage I have simplified the code down to typical Master-Details Pages (Separate) using a QueryString to filter the SelectCommand. But nothing seems to work.
Please help! I have wasted so much time trying to resolve this and I am on deadline and need this to work.
Thanks
Dave

View 3 Replies View Related

Edit Function In DetailsView

May 1, 2006

Hello
Am developing a web site using ASP.net 2.0. I have page to manage the employees information in term of viewing, inserting and updating. The problem is that the updating part doesn't work and it didn't give me any error messages.
My code is as following:
<%@ Page Language="VB" AutoEventWireup="false"%>
 
<!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 runat="server">
    <title>Untitled Page</title>
</head>
<script runat="server" >
   
    Protected Sub DetailsView1_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertedEventArgs)
   
        If (Not e.Exception Is Nothing) Then
 
            ErrorMessageLabel.Text = "An error occured while entering this record.  Please verify you have entered data in the correct format."
            e.ExceptionHandled = True
        End If
        GridView1.DataBind()
    End Sub
 
    Protected Sub DetailsView1_ItemUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdatedEventArgs)
   
        GridView1.DataBind()
    End Sub
 
    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
    
        DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)
    End Sub
 
    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
   
        DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)
    End Sub
 
    Protected Sub GridView1_PageIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
   
        DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)
    End Sub
 
    Protected Sub GridView1_Sorted(ByVal sender As Object, ByVal e As System.EventArgs)
        DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)
    End Sub
   
</script>
<body dir="rtl">
    <form id="form1" runat="server">
        <br />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:warehouse DBConnectionString2 %>"
            ProviderName="<%$ ConnectionStrings:warehouse DBConnectionString2.ProviderName %>"
            SelectCommand="SELECT DISTINCT [dep_Code], [dep_Name], [BRN_Code] FROM [Departments]"></asp:SqlDataSource>
       
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:warehouse DBConnectionString2 %>"
            ProviderName="<%$ ConnectionStrings:warehouse DBConnectionString2.ProviderName %>"
            SelectCommand="SELECT DISTINCT [ID], [Name],[Position], [DEPT_Code] FROM [Employees]
            where [DEPT_Code]=@dep_Name">
        <SelectParameters>
        <asp:ControlParameter ControlID="DropDownList1" Name="dep_Name" Type="Int32" />
        </SelectParameters>
        </asp:SqlDataSource>
       
        <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:warehouse DBConnectionString2 %>"
            ProviderName="<%$ ConnectionStrings:warehouse DBConnectionString2.ProviderName %>"
            SelectCommand="SELECT DISTINCT [ID], [Authentication], [Name], [Password], [Position], [DEPT_Code], [Contact] FROM [Employees]
            where [ID]=@ID "
           
            UpdateCommand="UPDATE [Employees]
                           SET
                           [ID] = @ID,
                             [Authentication]=@Authentication,
                             [Name]=@Name,
                             [Password]=@Password,
                           [Position]=@Position,
                             [DEPT_Code]=@DEPT_Code,
                             [Contact]=@Contact
                           WHERE [ID] = @ID  "
                           
            InsertCommand="INSERT INTO [Employees]
                   ([ID], [Authentication], [Name], [Password], [Position], [DEPT_Code], [Contact])
            Values (@ID, @Authentication, @Name, @Password, @Position, @DEPT_Code, @Contact) "
            >
        <SelectParameters>
        <asp:ControlParameter ControlID="GridView1" Name="ID" Type="Int32"  PropertyName="SelectedValue" />
        </SelectParameters>
       
        <UpdateParameters>
        <asp:Parameter Name="ID" Type="Int32" />
        <asp:Parameter Name="Authentication" Type="Int16" />
        <asp:Parameter Name="Name" Type="String" />
        <asp:Parameter Name="Password" Type="String" />
        <asp:Parameter Name="Position" Type="String" />
        <asp:Parameter Name="DEPT_Code" Type="Int32" />
        <asp:Parameter Name="Contact" Type="String" />
        </UpdateParameters>
       
        <InsertParameters>
        <asp:Parameter Name="ID" Type="Int32" />
        <asp:Parameter Name="Authentication" Type="Int16" />
        <asp:Parameter Name="Name" Type="String" />
        <asp:Parameter Name="Password" Type="String" />
        <asp:Parameter Name="Position" Type="String" />
        <asp:Parameter Name="DEPT_Code" Type="Int32" />
        <asp:Parameter Name="Contact" Type="String" />
        </InsertParameters>
        </asp:SqlDataSource>
        &nbsp;
        <br />
        <br />
        أختر القسم :&nbsp;
        <asp:DropDownList ID="DropDownList1" DataSourceID="SqlDataSource1" AutoPostBack="True"
      DataTextField="dep_Name" runat="server" DataValueField="dep_Code" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" >
        <asp:ListItem></asp:ListItem>
    </asp:DropDownList>
        <table >
            <tr>
                <td style="width: 100px">
                </td>
                <td style="width: 100px">
                </td>
            </tr>
            <tr>
                <td style="width: 100px; height: 154px" valign="top">
                    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID"
                        DataSourceID="SqlDataSource2" AllowPaging="True" AllowSorting="True" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnPageIndexChanged="GridView1_PageIndexChanged">
                        <Columns>
                            <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID" />
                           
                            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                            <asp:BoundField DataField="Position" HeaderText="Position" SortExpression="Position" />
                            <asp:BoundField DataField="DEPT_Code" HeaderText="DEPT_Code" SortExpression="DEPT_Code" Visible="False" />
                           
                            <asp:CommandField ShowSelectButton="True" />
                        </Columns>
                    </asp:GridView>
                </td>
                <td style="width: 100px; height: 154px" valign="top">
                    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="ID" OnItemUpdated="DetailsView1_ItemUpdated"
                        DataSourceID="SqlDataSource3" Height="50px" Width="125px" AllowPaging="True" OnItemInserted="DetailsView1_ItemInserted">
                        <Fields>
                            <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID" />
                            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                            <asp:BoundField DataField="Password" HeaderText="Password" SortExpression="Password" />
                            <asp:BoundField DataField="Position" HeaderText="Position" SortExpression="Position" />
                            <asp:BoundField DataField="Contact" HeaderText="Contact" SortExpression="Contact" />
                            <asp:TemplateField HeaderText="Department" SortExpression="DEPT_Code" >
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%#Eval("DEPT_Code") %>'></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource1"
                                    DataTextField="dep_Name" DataValueField="dep_Code" SelectedValue='<%# Bind("DEPT_Code") %>'>
                                    </asp:DropDownList>
                                </EditItemTemplate>
                                <InsertItemTemplate>
                                <asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="SqlDataSource1"
                                DataTextField="dep_Name" DataValueField="dep_Code" SelectedValue='<%# Bind("DEPT_Code") %>'>
                                </asp:DropDownList>
                                </InsertItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Authentication" SortExpression="Authentication">
                            <ItemTemplate>
                                <asp:Label ID="Label2" runat="server" Text='<%#Eval("Authentication") %>'></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:DropDownList ID="DropDownList4" runat="server" SelectedValue='<%# Bind("Authentication") %>'>
                                <asp:ListItem Text="Admin_User" Value="1" />
                                <asp:ListItem Text="Super_User" Value="2" />
                                <asp:ListItem Text="Normal_User" Value="3" />
                                </asp:DropDownList>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                            <asp:DropDownList ID="DropDownList5" runat="server" SelectedValue='<%# Bind("Authentication") %>'>
                                <asp:ListItem Text="Admin_User" Value="1" />
                                <asp:ListItem Text="Super_User" Value="2" />
                                <asp:ListItem Text="Normal_User" Value="3" />
                                </asp:DropDownList>
                            </InsertItemTemplate>
                            </asp:TemplateField>
                            <asp:CommandField ShowInsertButton="True" />
                            <asp:CommandField ShowEditButton="True" />
                        </Fields>
                    </asp:DetailsView>
                </td>
            </tr>
        </table>
      
       <asp:Label ID="ErrorMessageLabel" EnableViewState="false" runat="server" />
    </form>
</body>
</html>
  

View 4 Replies View Related

Can't Update A Record Using A DetailsView And SqlDataSource

Feb 13, 2007

Hi,I'm trying to create a registration page that I've divided into multiple pages (first page for basic details, next page for address, etc.). I insert the record in the first page, and update it in the other pages. I pass the newly created ID to the other pages using the Page.PreviousPage property.  In the second page, I have the SqlDataSource configured as "SELECT * FROM [Table] WHERE ID = ?", and the UpdateCommand is "UPDATE .... WHERE ID = ?".  In Page_Load, I am updating the SelectCommand to "SELECT ... WHERE ID = " & intID, and the UpdateCommand similarly. The I do a dtlsvw.Databind()But when I go to the next page (the newly created ID is being passed properly), the update doesn't do anything. The new record doesn't contain the values in the detailsview. Can somebody help me out? Thanks,Wild Thing 

View 2 Replies View Related

SQLDataSource, Stored Procedure, DetailsView

Jul 30, 2007

For some reason I can't make the stars align.  Could someone spot the problem here?  I'm looking to select the Identity of my last inserted record in the code behind my DetailsView.  Here are the relavent bits:
Stored Procedure:ALTER PROCEDURE usp_EW_INSERTMajor
@StartDate datetime, @Finishdate datetime, @ProjectName nvarchar(1000), @WorkCell nvarchar(1000),
@JobName nvarchar(1000), @PartName nvarchar(1000), @StatusID int, @ResponsibleID int, @FacilityID int

AS
Set nocount on

DECLARE @ProjectID int
/*This saves the bits to the Project table*/
INSERT INTO EW_Project (ProjectTypeID,FacilityID,StartDate,FinishDate,Status,EmployeeID)
VALUES(1,@FacilityID,@StartDate,@FinishDate,@StatusID,@ResponsibleID)


/*This saves the bits to the Major table*/



SET @ProjectID = SCOPE_IDENTITY()
INSERT INTO EW_MajorBasic(ProjectID,ProjectName,WorkCell,JobName,PartName)
VALUES (@ProjectID,@Projectname,@WorkCell,@JobName,@PartName)

Set nocount off

SELECT @ProjectID as ProjectID
 
SQLDataSource<asp:SqlDataSource ID="ProjectData" runat="server" ConnectionString="<%$ ConnectionStrings:myConnectionString %>"
SelectCommand="usp_EW_GETMajorBasic"
SelectCommandType="StoredProcedure"
UpdateCommand="usp_EW_UPDATEMajorBasic"
InsertCommand="usp_EW_INSERTMajor"
InsertCommandType="StoredProcedure"
UpdateCommandType="StoredProcedure"
DeleteCommand="DELETE FROM EW_Project WHERE ProjectID = @ProjectID"
>
<UpdateParameters>
<asp:Parameter Name="ProjectID" Type="Int32" />
<asp:Parameter Name="StartDate" Type="DateTime" />
<asp:Parameter Name="Finishdate" Type="DateTime" />
<asp:Parameter Name="ProjectName" Type="String" />
<asp:Parameter Name="WorkCell" Type="String" />
<asp:Parameter Name="JobName" Type="String" />
<asp:Parameter Name="PartName" Type="String" />
<asp:Parameter Name="StatusID" Type="Int32" />
<asp:Parameter Name="ResponsibleID" Type="Int32" />
<asp:CookieParameter CookieName="EW_FacilityID" Name="FacilityID" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="StartDate" Type="DateTime" />
<asp:Parameter Name="Finishdate" Type="DateTime" />
<asp:Parameter Name="ProjectName" Type="String" />
<asp:Parameter Name="WorkCell" Type="String" />
<asp:Parameter Name="JobName" Type="String" />
<asp:Parameter Name="PartName" Type="String" />
<asp:Parameter Name="StatusID" Type="Int32" />
<asp:Parameter Name="ResponsibleID" Type="Int32" />
<asp:CookieParameter CookieName="EW_FacilityID" Name="FacilityID" />
</InsertParameters>
<SelectParameters>
<asp:Parameter Name="ProjectID" Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="ProjectID" />
</DeleteParameters>
</asp:SqlDataSource>
 
DetailsView<asp:DetailsView
ID="DetailsView1"
runat="server"
AutoGenerateRows="False"
DataKeyNames="ProjectID"
DataSourceID="ProjectData"
SkinID="SimpleDetailsView"
OnItemDeleted="ProjectData_Deleted"
OnItemInserted="DetailsView1_ItemInserted">  
 
Code-Behind: Sub DetailsView1_ItemInserted(ByVal sender As Object, ByVal e As DetailsViewInsertedEventArgs) Handles DetailsView1.ItemInserted
Dim newID As Integer = e.Values("ProjectID")
testlabel.Text = newID
End Sub
 
 
To be clear, everything is working.  When I come to this page with an ID, the records display fine (Select works).  The Update and Delete work just fine.  The Insert works fine too.  It's just that the ItemInserted part does not want to grab the ProjectID.  Specifically, testlabel displays a Zero. 

View 2 Replies View Related

GridViews/DetailsView (only Appear After Control Selection)

May 5, 2008

Hi all,I want to be able to implement what the following site shows in regards to dynamically displaying Data views of various types: http://quickstarts.asp.net/QuickStartv20/aspnet/samples/data/GridViewMasterDetails_vb.aspx I follow everything to the 'T' but for some reason all my data views are showing even before any initial selection is made in the drop down.  How can I have certain grids appear only after a selection from another control has been made?Thanks in advance,Nick  

View 1 Replies View Related

Images Inside Gridview And Detailsview

Mar 20, 2008

I have been stuck on this problem for over a week, and have ripped out about all of my hair, so here it goes.

I am working on a portfolio on a website that administrators are allowed to update, but the public may only view....easy enough? The grid has three parameters; CatID, Descrip, and Pic - as seen below.


<asp:SqlDataSource ID="SqlDataSource2" runat="server"


ConnectionString="<%$ ConnectionStrings:NORTHWNDConnectionString %>"




SelectCommand="SELECT [CatID], [Descrip], [Pic] FROM [Categories]"




UpdateCommand="UPDATE Categories SET Descrip = @Descrip, Pic = @Pic WHERE CatID = @CatID"

DeleteCommand="DELETE FROM Categories WHERE CatID = @CatID"




InsertCommand="INSERT INTO [Categories] ([CatID], [Descrip], [Pic]) VALUES (@CatID, @Descrip, @Pic)" >



<DeleteParameters>


<asp:Parameter Name="CatID" Type="String" />

<asp:parameter Name="Descrip" />

</DeleteParameters>



<UpdateParameters>


<asp:parameter Name="Descrip" />

<asp:parameter Name="Pic" />

<asp:parameter Name="CatID" Type="String" />

</UpdateParameters>



<insertparameters>


<asp:parameter Name="CatID" Type="String" />

<asp:parameter Name="Descrip" Type="String" />

<asp:parameter Name="Pic" Type="String"/>

</insertparameters>

</asp:SqlDataSource>

The first this I am not sure of, is whether Pic should be a String or not.

Basically I am using Detailsview for the administrator to update, and the gridview for the public view.


<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True"



AutoGenerateRows="False" DataKeyNames="CatID" HeaderText = "Portfolio"

DataSourceID="SqlDataSource2" Height="50px"

Width="300px" Font-Size = "14px" HeaderStyle-Font-Size="Larger" HeaderStyle-BackColor ="#27437D" HeaderStyle-ForeColor = "White"

BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px"

CellPadding="3" GridLines="Vertical">

<footerstyle backcolor="#CCCCCC" forecolor="Black" />

<rowstyle backcolor="#EEEEEE" forecolor="Black" />

<pagerstyle backcolor="#999999" forecolor="Black" horizontalalign="Center" />

<Fields>


<asp:boundfield DataField="CatID" HeaderText="Building/Job Name" ReadOnly="True" SortExpression="CatID">

</asp:boundfield>

<asp:boundfield DataField="Descrip" HeaderText="Description" SortExpression="CompanyName">

</asp:boundfield>

<asp:TemplateField HeaderText="Picture">


<EditItemTemplate>


<asp:TextBox ID="TextBox1" runat="server" Text='<%#Eval("Pic")%>' ></asp:TextBox>

</EditItemTemplate>

<InsertItemTemplate>


<asp:TextBox ID="TextBox1" runat="server" Text='<%#Eval("Pic")%>' ></asp:TextBox>

</InsertItemTemplate>

<ItemTemplate>


<asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("Pic") %>' />

</ItemTemplate>

</asp:TemplateField>

<asp:commandfield ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True">

</asp:commandfield>

</Fields>

<HeaderStyle BackColor="#27437D" Font-Size="Larger" ForeColor="White"></HeaderStyle>

<alternatingrowstyle backcolor="#DCDCDC" />

</asp:DetailsView>

And my Gridview...

<asp:GridView ID= "GridView1" runat="server" DataSourceID="SqlDataSource2" AllowSorting="True" BackColor="White" CellPadding="3" Caption = "Portfolio"


Font-Size ="14px" BorderColor="#999999"BorderStyle="None"BorderWidth="1px"GridLines="Vertical"AutoGenerateColumns="False">

<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />

<RowStyle BackColor="#EEEEEE" Font-Size = "Small" ForeColor="Black" />

<columns>


<asp:boundfield DataField="CatID" HeaderText="Building/Job Name"></asp:boundfield>

<asp:boundfield DataField="Descrip" HeaderText="Description"></asp:boundfield>







<asp:TemplateField HeaderText="Picture">


<EditItemTemplate>


<asp:TextBox ID="TextBox1" runat="server" text='<%# Eval("Pic") %>'

></asp:TextBox>

</EditItemTemplate>

<ItemTemplate>


<asp:Image ID="Image1" runat="server" ImageUrl= '<%# Eval("Pic") %>' />



</ItemTemplate>

</asp:TemplateField>



</columns>

<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />

<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />

<HeaderStyle BackColor="#27437D" Font-Bold="True" ForeColor="White" />

<AlternatingRowStyle BackColor="#DCDCDC" />

</asp:GridView>


Now as I was looking around on the web I saw many people converting the path of the image to binary and the casting it to the DB, and likewise retrieving it from the DB as binary and converting it to an image, the problem is, I don't know how to do this.

Any help to ease my troubles is apprechiated greatly.

Edit: Also I am not totally sure what the '<%Eval("Pic") %>' is doing, it was autofilled for me.
Edit again: Another thing, if I replace any of the ImageUrl to an image path on the computer it does fill the space in the gridview/detailsview. However, with both cases I get a Operand type clash: nvarchar is incompatible with image error.

View 1 Replies View Related

Stored Procdure To Update Two Tables While In Detailsview

Feb 21, 2008

I am using a stored procedure to update data while in detailsview.I am having a rough time. Dont know why this wont workthanks a lotheres my codeALTER PROCEDURE UpdateCustomerInfo    ( @CustomerID as INT, @LName as varchar(50), @FName as varchar(50), @Dept as varchar(50)=NULL, @PhoneType as varchar(50)=NULL, @OfficeType as varchar(50) = NULL, @Ext as Int=NULL, @BridgeExt as int=NULL, @Workstation as varchar(50)=NULL, @OldPrinters as varchar(50)=NULL, @NewPrinters as varchar(50)=NULL, @PhoneImg as varchar(50)=NULL, @OfficeImg as varchar(50)=NULL, @Complete as Bit=NULL, @FaxModel as varchar(50)=NULL, @FaxNumber as varchar(50)=NULL, @ConfPhone as varchar(50)=NULL, @ConfExt as varchar(50)=NULL, @ReutersDacsId as Varchar(50)=NULL, @Bloomberg as Varchar(50)=NULL, @NewFloor as Int=NULL, @OldFloor as Int=NULL )AS    UPDATE CustomerInfo SET LName = @LName, FName = @FName, Dept = @Dept, PhoneType = @PhoneType, Ext = @Ext, BridgeExt = @BridgeExt, Workstation = @Workstation, OldPrinters = @OldPrinters, NewPrinters = @NewPrinters, OfficeImg = @OfficeImg, PhoneImg = @PhoneImg, Complete = @Complete Where CustomerId = @CustomerId        UPDATE Extras SET CustomerID = @CustomerID, FaxModel=@FaxModel, FaxNumber=@FaxNumber, ConfPhone=@ConfPhone, ConfExt=@ConfExt, ReutersDacsId=@ReutersDacsId, Bloomberg=@Bloomberg where CustomerID = @CustomerID        RETURN 

View 2 Replies View Related

Event To Catch A Primary Key Violation In A DetailsView?

Apr 23, 2008

I have a SQLDataSource bound to a DetailsView.  In which event would I catch a Primary Key violation?  Would be an event of the SQLDataSource or the DetailsView?  And which particular event?  A small example would be great.  Thx.

View 1 Replies View Related

Detailsview Control - How To Edit Record In Sql Server Express

Aug 25, 2006

I have null values in some of the fields & when I use EDIT to make changes these changes are not recorded + I receive no error.  

View 1 Replies View Related







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