Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DetailView

Reply
Thread Tools

DetailView

 
 
viktor
Guest
Posts: n/a
 
      07-30-2007
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 />

<aspetailsView 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>

</aspetailsView>

<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>

<asparameter Name="original_inv_mast_uid" Type="Int32" />

<asparameter Name="original_item_id" Type="String" />

<asparameter Name="original_item_description" Type="String" />

<asparameter Name="original_qty_on_hand" Type="Decimal" />

<asparameter Name="original_uom" Type="String" />

</DeleteParameters>

<UpdateParameters>

<asparameter Name="item_id" Type="String" />

<asparameter Name="item_description" Type="String" />

<asparameter Name="qty_on_hand" Type="Decimal" />

<asparameter Name="uom" Type="String" />

<asparameter Name="original_inv_mast_uid" Type="Int32" />

<asparameter Name="original_item_id" Type="String" />

<asparameter Name="original_item_description" Type="String" />

<asparameter Name="original_qty_on_hand" Type="Decimal" />

<asparameter Name="original_uom" Type="String" />

</UpdateParameters>

<SelectParameters>

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

</SelectParameters>

<InsertParameters>

<asparameter Name="item_id" Type="String" />

<asparameter Name="item_description" Type="String" />

<asparameter Name="qty_on_hand" Type="Decimal" />

<asparameter Name="uom" Type="String" />

</InsertParameters>

</asp:SqlDataSource>

</asp:Content>

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

</asp:Content>



ANY HELP PLEASE


 
Reply With Quote
 
 
 
 
Brandon Gano
Guest
Posts: n/a
 
      07-30-2007
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.


"viktor" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>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 />
>
> <aspetailsView 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>
>
> </aspetailsView>
>
> <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>
>
> <asparameter Name="original_inv_mast_uid" Type="Int32" />
>
> <asparameter Name="original_item_id" Type="String" />
>
> <asparameter Name="original_item_description" Type="String" />
>
> <asparameter Name="original_qty_on_hand" Type="Decimal" />
>
> <asparameter Name="original_uom" Type="String" />
>
> </DeleteParameters>
>
> <UpdateParameters>
>
> <asparameter Name="item_id" Type="String" />
>
> <asparameter Name="item_description" Type="String" />
>
> <asparameter Name="qty_on_hand" Type="Decimal" />
>
> <asparameter Name="uom" Type="String" />
>
> <asparameter Name="original_inv_mast_uid" Type="Int32" />
>
> <asparameter Name="original_item_id" Type="String" />
>
> <asparameter Name="original_item_description" Type="String" />
>
> <asparameter Name="original_qty_on_hand" Type="Decimal" />
>
> <asparameter Name="original_uom" Type="String" />
>
> </UpdateParameters>
>
> <SelectParameters>
>
> <asp:ControlParameter ControlID="itemID" Name="item_id"
> PropertyName="Text" Type="String" />
>
> </SelectParameters>
>
> <InsertParameters>
>
> <asparameter Name="item_id" Type="String" />
>
> <asparameter Name="item_description" Type="String" />
>
> <asparameter Name="qty_on_hand" Type="Decimal" />
>
> <asparameter Name="uom" Type="String" />
>
> </InsertParameters>
>
> </asp:SqlDataSource>
>
> </asp:Content>
>
> <asp:Content ID="Content2" ContentPlaceHolderID="leftColumn"
> Runat="Server">
>
> </asp:Content>
>
>
>
> ANY HELP PLEASE
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formating a date field in ASP .Net 2.0 detailview =?Utf-8?B?Sm9obiBCYWlsZXk=?= ASP .Net 3 04-29-2010 09:40 AM
DetailView Data Update Error Henry Lee ASP .Net 0 03-02-2006 07:41 PM
detailview loses components after refresh Mike ASP .Net 0 01-31-2006 10:31 PM
DetailView =?Utf-8?B?QXJuZQ==?= ASP .Net 3 01-27-2006 01:28 PM
xpo objectdatasource gridview detailview Kha Tran ASP .Net 0 06-03-2005 09:22 AM



Advertisments