Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

DetailView

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
viktor - 30 Jul 2007 21:18 GMT
I am having a problem cahnging default mode in the code.What i am trying to
do is: on page load event:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load

If Page.IsPostBack Then

itemview.DefaultMode = DetailsViewMode.ReadOnly

Else

itemview.DefaultMode = DetailsViewMode.Insert

End If

End Sub

i have a txt box and when i change a value and hit enter to post back it
doesn't change the mode on detailsview.

here my aspx code:

<%@ Page Language="VB" MasterPageFile="~/AppMaster.master"
AutoEventWireup="false" CodeFile="Inventory_entry.aspx.vb"
Inherits="admin_customer_Inventory_entry" title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="mainCopy" Runat="Server">

<br />Item Id:

<asp:TextBox ID="itemID" runat="server" Text='<%# Bind("item_id") %>'
AutoPostBack="True"></asp:TextBox>&nbsp;<asp:Button

ID="Button1" runat="server" Text="Button" /><br />

<br />

<asp:DetailsView ID="itemview" runat="server" AutoGenerateRows="False"
DataKeyNames="inv_mast_uid"

DataSourceID="inventoryateset" Height="50px" Width="219px">

<Fields>

<asp:BoundField DataField="inv_mast_uid" HeaderText="inv_mast_uid"
InsertVisible="False"

ReadOnly="True" SortExpression="inv_mast_uid" />

<asp:BoundField DataField="item_id" HeaderText="item_id"
SortExpression="item_id" />

<asp:BoundField DataField="item_description" HeaderText="item_description"
SortExpression="item_description" />

<asp:BoundField DataField="qty_on_hand" HeaderText="qty_on_hand"
SortExpression="qty_on_hand" />

<asp:BoundField DataField="uom" HeaderText="uom" SortExpression="uom" />

<asp:CommandField ShowDeleteButton="True" ShowEditButton="True"
ShowInsertButton="True" />

</Fields>

</asp:DetailsView>

<asp:SqlDataSource ID="inventoryateset" runat="server"
ConflictDetection="CompareAllValues"

ConnectionString="<%$ ConnectionStrings:KeaneConnectionString %>"
DeleteCommand="DELETE FROM [inventory] WHERE [inv_mast_uid] =
@original_inv_mast_uid AND [item_id] = @original_item_id AND
[item_description] = @original_item_description AND [qty_on_hand] =
@original_qty_on_hand AND [uom] = @original_uom"

InsertCommand="INSERT INTO [inventory] ([item_id], [item_description],
[qty_on_hand], [uom]) VALUES (@item_id, @item_description, @qty_on_hand,
@uom)"

OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM
[inventory] WHERE ([item_id] = @item_id)"

UpdateCommand="UPDATE [inventory] SET [item_id] = @item_id,
[item_description] = @item_description, [qty_on_hand] = @qty_on_hand, [uom]
= @uom WHERE [inv_mast_uid] = @original_inv_mast_uid AND [item_id] =
@original_item_id AND [item_description] = @original_item_description AND
[qty_on_hand] = @original_qty_on_hand AND [uom] = @original_uom">

<DeleteParameters>

<asp:Parameter Name="original_inv_mast_uid" Type="Int32" />

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

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

<asp:Parameter Name="original_qty_on_hand" Type="Decimal" />

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

</DeleteParameters>

<UpdateParameters>

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

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

<asp:Parameter Name="qty_on_hand" Type="Decimal" />

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

<asp:Parameter Name="original_inv_mast_uid" Type="Int32" />

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

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

<asp:Parameter Name="original_qty_on_hand" Type="Decimal" />

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

</UpdateParameters>

<SelectParameters>

<asp:ControlParameter ControlID="itemID" Name="item_id" PropertyName="Text"
Type="String" />

</SelectParameters>

<InsertParameters>

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

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

<asp:Parameter Name="qty_on_hand" Type="Decimal" />

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

</InsertParameters>

</asp:SqlDataSource>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="leftColumn" Runat="Server">

</asp:Content>

ANY HELP PLEASE
Brandon Gano - 30 Jul 2007 22:23 GMT
Try moving that code to Page_Init. I think the viewstate is being saved
before you make that change, so it doesn't push through to the output.

>I am having a problem cahnging default mode in the code.What i am trying to
>do is: on page load event:
[quoted text clipped - 150 lines]
>
> ANY HELP PLEASE

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.