Hi, David:
Thanks for your reply, I set the defaulemode as edit. But i kept
getting error
OnModeChanging, OnUpdating event not handled error. I did not using
DataSourceID since my website is a 3-tiers structure, I have a business
logic layer so basically put sql statement on the page is out of the
question.
I attached my source code below see if you can give me a hand what am I
missing?
It is a sample detailsview with NAME textbox field and STATE
DropDownList field. (I removed other fields for easier reading)
When user click a member on my gridview( not show here) , I will
databind this detailsview and the user can edit immediately (not by
click edit button). detailsview databinding and dropdownlist
databinding are in code behind and works fine.
Should I remove the command field for (update /edit) and use my own?
Thanks a lot
-rockdale
------------------------------------------
<asp:DetailsView ID="detlMemb" runat="server"
AutoGenerateRows="False" DataKeyNames="member_id"
DefaultMode="Edit"
HeaderText="Member"
EnableViewState="True"
OnDataBound="DetlMemb_OnDataBound"
OnItemInserted="DetlMemb_OnItemInserted"
OnItemUpdated="DetlMemb_OnItemUpdated"
>
<Fields>
<asp:BoundField DataField="member_id"
HeaderText="Member ID" SortExpression="member_id" Visible="false" />
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<asp:TextBox ID="txtmember_name"
runat="server" Text='<%# Eval("member_name") %>'
Width="80px"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="State" >
<ItemTemplate>
<asp:DropDownList ID="ddlstate"
runat="server"
AppendDataBoundItems="true"
DataTextField="state_id" DataValueField="state_id">
<asp:ListItem
Value="">Select...</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True"
EditText="Save" ShowInsertButton="True" InsertText="New"/>
</Fields>
</asp:DetailsView>
David Wier wrote:
You should be able to use the DefaultMode property, setting it to 'Edit'
--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"rockdale" <ro************@gmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
Hi,
I am upgrading my asp.net 1.x to asp.net 2.0. In my page I have a
datagrid and a group of textbox, dropdownlist, checkbox... etc. the
datagrid and the group of controls are hooked up - when user click on
datagrid to select a row, then I will populate the record detail to
those controls for user to edit.
As in asp.net 2.0, I tried to use detailsview to replace the group of
controls by using <ItemTemplate>. But I do not like the user has to
click edit/insert button to change read-only to edit mode. I want the
detailsview always in edit/insert mode so that the user can edit
/insert then click a save button to save changes. Can I achive this? I
tried to use ItemTemplate but got lots of problems. Any example for a
edit-mode only detailview/formview?
Thanks a lot
-rockdale