Solved

Ucase in ASP.NET in DetailView

Posted on 2006-06-19
13
850 Views
Last Modified: 2008-02-26



I have a Detailview Table linked to a sql database and in the detailview, I have Insert enabled.  My question is, how do I add Ucase as a string in the detailview table to allow all Uppercase letters in a sql field.
0
Comment
Question by:JWFreedom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
13 Comments
 
LVL 7

Expert Comment

by:kGenius
ID: 16940107
can you be more clear?
You want to UPPERCASE string as data in sql fields (inserted from the detailsview insert mode?)
Or do you want uppercase all characters before inserting in SQL?
ie
my string --> <submit> --> MY STRING --> <insert in SQL>
?
0
 

Author Comment

by:JWFreedom
ID: 16942940
Exactly,,, before it goes to sql,  [text] <insert> [TEXT] in SQL
0
 
LVL 7

Expert Comment

by:kGenius
ID: 16943023
INSERT INTO YourTable(field) VALUES(UCASE(Value))

Hope this'll help
kGenius
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:JWFreedom
ID: 16944602
Would I put this in the Source code,
0
 

Author Comment

by:JWFreedom
ID: 16944621
This is what the stirng looks like:
 <asp:Parameter Name="PC_Name" Type="String" />
0
 
LVL 7

Expert Comment

by:kGenius
ID: 16944628
You put this in your Insert statement (SQL)
0
 

Author Comment

by:JWFreedom
ID: 16944669
I'm not sure whee that is,  Remeber, this is a table that is used from ASP.  I did not create a table from scratch,  I used the one provide from Visual Web Developer Express.  So everything is pretty much in ASP


<InsertParameters>
                <asp:Parameter Name="Employee" Type="String" />
                <asp:Parameter Name="PC_Name" Type="String" />
                <asp:Parameter Name="PC_Type" Type="String" />
                <asp:Parameter Name="PC_Model" Type="String" />
                <asp:Parameter Name="Service_Tag_ID" Type="String" />
                <asp:Parameter Name="Express_Service_Code" Type="String" />
                <asp:Parameter Name="Warranty_Status" Type="String" />
                <asp:Parameter Name="Memory" Type="String" />
                <asp:Parameter Name="Monitor_Type" Type="String" />
                <asp:Parameter Name="Network_Connectivity" Type="String" />
                <asp:Parameter Name="Carrying_Case_Type" Type="String" />
                <asp:Parameter Name="Miscellaneous" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
0
 
LVL 7

Expert Comment

by:kGenius
ID: 16944684
Can you post your entire <asp:SqlDataSource> tag?
0
 

Author Comment

by:JWFreedom
ID: 16944692
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Inventory.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 runat="server">
    <title>FTC Inventory Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <strong>FTC INVENTORY PAGE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            <br />
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
            &nbsp; &nbsp;&nbsp;
            <asp:Label ID="Label1" runat="server" Font-Bold="True" Text="Detail View" Width="83px"></asp:Label></strong><br />
        <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False"
            CellPadding="2" CellSpacing="2" DataKeyNames="ID" DataSourceID="SqlDataSource1"
            Height="50px" Width="501px">
            <Fields>
                <asp:BoundField DataField="Employee" HeaderText="Employee Name (Last, First):" SortExpression="Employee" />
                <asp:BoundField DataField="PC_Name" HeaderText="Computer Name on Domain:" SortExpression="PC_Name" />
                <asp:BoundField DataField="PC_Type" HeaderText="Type of Computer (Laptop, Desktop):"
                    SortExpression="PC_Type" />
                <asp:BoundField DataField="PC_Model" HeaderText="Make and Model of Computer:" SortExpression="PC_Model" />
                <asp:BoundField DataField="Service_Tag_ID" HeaderText="Service Tag ID:" SortExpression="Service_Tag_ID" />
                <asp:BoundField DataField="Express_Service_Code" HeaderText="Express Service Code:"
                    SortExpression="Express_Service_Code" />
                <asp:BoundField DataField="Warranty_Status" HeaderText="Warranty Status (In Days):"
                    SortExpression="Warranty_Status" />
                <asp:BoundField DataField="Memory" HeaderText="Amount of Memory:" SortExpression="Memory" />
                <asp:BoundField DataField="Monitor_Type" HeaderText="Monitor Make and Size:" SortExpression="Monitor_Type" />
                <asp:BoundField DataField="Network_Connectivity" HeaderText="Network Connectivity:"
                    SortExpression="Network_Connectivity" />
                <asp:BoundField DataField="Carrying_Case_Type" HeaderText="Carrying Case/Brand:"
                    SortExpression="Carrying_Case_Type" />
                <asp:BoundField DataField="Miscellaneous" HeaderText="Miscellaneous:" SortExpression="Miscellaneous" />
                <asp:CommandField ShowInsertButton="True" ShowDeleteButton="True" ShowEditButton="True" />
            </Fields>
            <AlternatingRowStyle BackColor="#E0E0E0" />
        </asp:DetailsView>
        <asp:Button ID="Button1" runat="server" Text="VIEW GRID" ToolTip="View all records" />
        &nbsp; &nbsp; &nbsp; &nbsp;<asp:Button ID="Button2" runat="server"
            Text="VIEW DETAIL" ToolTip="View/insert single record" />
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:INVENTORYConnectionString3 %>"
            DeleteCommand="DELETE FROM [INVENTORY] WHERE [ID] = @ID" InsertCommand="INSERT INTO [INVENTORY] ([Employee], [PC_Name], [PC_Type], [PC_Model], [Service_Tag_ID], [Express_Service_Code], [Warranty_Status], [Memory], [Monitor_Type], [Network_Connectivity], [Carrying_Case_Type], [Miscellaneous]) VALUES (@Employee, @PC_Name, @PC_Type, @PC_Model, @Service_Tag_ID, @Express_Service_Code, @Warranty_Status, @Memory, @Monitor_Type, @Network_Connectivity, @Carrying_Case_Type, @Miscellaneous)"
            SelectCommand="SELECT * FROM [INVENTORY]" UpdateCommand="UPDATE [INVENTORY] SET [Employee] = @Employee, [PC_Name] = @PC_Name, [PC_Type] = @PC_Type, [PC_Model] = @PC_Model, [Service_Tag_ID] = @Service_Tag_ID, [Express_Service_Code] = @Express_Service_Code, [Warranty_Status] = @Warranty_Status, [Memory] = @Memory, [Monitor_Type] = @Monitor_Type, [Network_Connectivity] = @Network_Connectivity, [Carrying_Case_Type] = @Carrying_Case_Type, [Miscellaneous] = @Miscellaneous WHERE [ID] = @ID">
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="Employee" Type="String" />
                <asp:Parameter Name="PC_Name" Type="String" />
                <asp:Parameter Name="PC_Type" Type="String" />
                <asp:Parameter Name="PC_Model" Type="String" />
                <asp:Parameter Name="Service_Tag_ID" Type="String" />
                <asp:Parameter Name="Express_Service_Code" Type="String" />
                <asp:Parameter Name="Warranty_Status" Type="String" />
                <asp:Parameter Name="Memory" Type="String" />
                <asp:Parameter Name="Monitor_Type" Type="String" />
                <asp:Parameter Name="Network_Connectivity" Type="String" />
                <asp:Parameter Name="Carrying_Case_Type" Type="String" />
                <asp:Parameter Name="Miscellaneous" Type="String" />
                <asp:Parameter Name="ID" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="Employee" Type="String" />
                <asp:Parameter Name="PC_Name" Type="String" />
                <asp:Parameter Name="PC_Type" Type="String" />
                <asp:Parameter Name="PC_Model" Type="String" />
                <asp:Parameter Name="Service_Tag_ID" Type="String" />
                <asp:Parameter Name="Express_Service_Code" Type="String" />
                <asp:Parameter Name="Warranty_Status" Type="String" />
                <asp:Parameter Name="Memory" Type="String" />
                <asp:Parameter Name="Monitor_Type" Type="String" />
                <asp:Parameter Name="Network_Connectivity" Type="String" />
                <asp:Parameter Name="Carrying_Case_Type" Type="String" />
                <asp:Parameter Name="Miscellaneous" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
       <br />
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        <asp:Label ID="Label2" runat="server" Font-Bold="True" Text="Grid View" Visible="False"
            Width="74px"></asp:Label><br />
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
            CellSpacing="3" DataKeyNames="ID" DataSourceID="SqlDataSource2" AllowSorting="True" Visible="False">
            <Columns>
                <asp:CommandField ShowEditButton="True" />
                <asp:BoundField DataField="Employee" HeaderText="Employee Name" SortExpression="Employee" />
                <asp:BoundField DataField="PC_Name" HeaderText="Computer Name on Domain" SortExpression="PC_Name" />
                <asp:BoundField DataField="PC_Type" HeaderText="Type of Computer" SortExpression="PC_Type" />
                <asp:BoundField DataField="PC_Model" HeaderText="Make and Model of Computer" SortExpression="PC_Model" />
                <asp:BoundField DataField="Service_Tag_ID" HeaderText="Service Tag ID" SortExpression="Service_Tag_ID" />
                <asp:BoundField DataField="Express_Service_Code" HeaderText="Express Service Code"
                    SortExpression="Express_Service_Code" />
                <asp:BoundField DataField="Warranty_Status" HeaderText="Warranty Status" SortExpression="Warranty_Status" />
                <asp:BoundField DataField="Memory" HeaderText="Memory" SortExpression="Memory" />
                <asp:BoundField DataField="Monitor_Type" HeaderText="Monitor Type" SortExpression="Monitor_Type" />
                <asp:BoundField DataField="Network_Connectivity" HeaderText="Network Connectivity"
                    SortExpression="Network_Connectivity" />
                <asp:BoundField DataField="Carrying_Case_Type" HeaderText="Carrying Case Type" SortExpression="Carrying_Case_Type" />
                <asp:BoundField DataField="Miscellaneous" HeaderText="Miscellaneous" SortExpression="Miscellaneous" />
            </Columns>
            <AlternatingRowStyle BackColor="#E0E0E0" />
            <HeaderStyle BackColor="LightCyan" />
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:LABELID#ConnectionString %>"
            SelectCommand="SELECT * FROM [INVENTORY]" DeleteCommand="DELETE FROM [INVENTORY] WHERE [ID] = @ID" InsertCommand="INSERT INTO [INVENTORY] ([Employee], [PC_Name], [PC_Type], [PC_Model], [Service_Tag_ID], [Express_Service_Code], [Warranty_Status], [Memory], [Monitor_Type], [Network_Connectivity], [Carrying_Case_Type], [Miscellaneous]) VALUES (@Employee, @PC_Name, @PC_Type, @PC_Model, @Service_Tag_ID, @Express_Service_Code, @Warranty_Status, @Memory, @Monitor_Type, @Network_Connectivity, @Carrying_Case_Type, @Miscellaneous)" UpdateCommand="UPDATE [INVENTORY] SET [Employee] = @Employee, [PC_Name] = @PC_Name, [PC_Type] = @PC_Type, [PC_Model] = @PC_Model, [Service_Tag_ID] = @Service_Tag_ID, [Express_Service_Code] = @Express_Service_Code, [Warranty_Status] = @Warranty_Status, [Memory] = @Memory, [Monitor_Type] = @Monitor_Type, [Network_Connectivity] = @Network_Connectivity, [Carrying_Case_Type] = @Carrying_Case_Type, [Miscellaneous] = @Miscellaneous WHERE [ID] = @ID">
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="Employee" Type="String" />
                <asp:Parameter Name="PC_Name" Type="String" />
                <asp:Parameter Name="PC_Type" Type="String" />
                <asp:Parameter Name="PC_Model" Type="String" />
                <asp:Parameter Name="Service_Tag_ID" Type="String" />
                <asp:Parameter Name="Express_Service_Code" Type="String" />
                <asp:Parameter Name="Warranty_Status" Type="String" />
                <asp:Parameter Name="Memory" Type="String" />
                <asp:Parameter Name="Monitor_Type" Type="String" />
                <asp:Parameter Name="Network_Connectivity" Type="String" />
                <asp:Parameter Name="Carrying_Case_Type" Type="String" />
                <asp:Parameter Name="Miscellaneous" Type="String" />
                <asp:Parameter Name="ID" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="Employee" Type="String" />
                <asp:Parameter Name="PC_Name" Type="String" />
                <asp:Parameter Name="PC_Type" Type="String" />
                <asp:Parameter Name="PC_Model" Type="String" />
                <asp:Parameter Name="Service_Tag_ID" Type="String" />
                <asp:Parameter Name="Express_Service_Code" Type="String" />
                <asp:Parameter Name="Warranty_Status" Type="String" />
                <asp:Parameter Name="Memory" Type="String" />
                <asp:Parameter Name="Monitor_Type" Type="String" />
                <asp:Parameter Name="Network_Connectivity" Type="String" />
                <asp:Parameter Name="Carrying_Case_Type" Type="String" />
                <asp:Parameter Name="Miscellaneous" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
   
    </div>
    </form>
</body>

</html>
0
 

Author Comment

by:JWFreedom
ID: 16944999
I am getting an error stating that 'UCASE' is not a recognized function name. I placed the UCase just like this:
InsertCommand="INSERT INTO [INVENTORY] ([Employee], [PC_Name], [PC_Type], [PC_Model], [Service_Tag_ID], [Express_Service_Code], [Warranty_Status], [Memory], [Monitor_Type], [Network_Connectivity], [Carrying_Case_Type], [Miscellaneous]) VALUES (@Employee, (UCASE(@PC_Name)), @PC_Type, @PC_Model, @Service_Tag_ID, @Express_Service_Code, @Warranty_Status, @Memory, @Monitor_Type, @Network_Connectivity, @Carrying_Case_Type, @Miscellaneous)"

Is this wrong
0
 
LVL 7

Expert Comment

by:kGenius
ID: 16952650
Can't you just Ucase when showing the data on the page in your Select statement or ucase in templatefield of your detailsview (ie <%# UCase(Bind("PC_Name")) %> )
So not inserting ucased, but viewing it ucased.

The alternative way is to catch the inserting procedure and changing PC_Name parameter dynamicly...
Let me know if you need the code.

kGenius
0
 

Author Comment

by:JWFreedom
ID: 16955126
I would kind of like to have record saved in SQL as all in Caps.  PC_Name is acctually the Name of the Computer on the domain, so it has to be all caps, and when users go and input there info into this form, they usually place all characters as small caps.  I would like it to store as all caps.  

I want to thank you for your help so far, you guys are great....
0
 
LVL 7

Accepted Solution

by:
kGenius earned 500 total points
ID: 16974251
OK try this
Remove
<asp:Parameter Name="PC_Name" Type="String" />
from you sqldatasource

 in Code-behind
Protected Sub DetailsView1_ItemInserting(ByVal ByVal sender As Object, ByVal e As DetailsViewInsertEventArgs) Handles DetailsView1.ItemInserting

Dim sPcName As String = Ctype(DetailsView1.Rows(1).Cells(1).Controls(0), TextBox).Text
SqlDataSource1.InsertParameters.Add("PC_Name", UCase(sPcName))
SqlDataSource1.Insert()

End Sub

Hope this 'll help
kGenius
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question