473,416 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Datalist edit items not working

I have a DataList that I have set up to allow editing. The edit button does
go to the subroutine defined by OnEditCommand. The problem is that it
doesn't change the fields to editing fields. The textbox doesn't show from
the edititemtemplate section. I don't get any errors.

Do I need to do something special to tell it to do this?

Here is the datalist:

************************************************** ******************************************
<asp:datalist id="DataList1"
runat="server"
Width="100%"
BorderWidth="0px"
OnEditCommand="DataListEdit"
OnUpdateCommand="DataListUpdate"
OnCancelCommand="DataListCancel"
footerstyle-horizontalalign="center"
CellPadding="0"
CellSpacing="0"
Border="0"
style="margin:0">
<AlternatingItemStyle cssClass=alternateRow ></AlternatingItemStyle>
<ItemTemplate>
<table border="0" width="100%" CellPadding="0" CellSpacing="0"
style="margin:0">
<tr>
<td width="100%">
<%# DataBinder.Eval(Container.DataItem, "Question") %>
</td>
<td width="30">
<asp:button Text="Edit" runat="server" CommandName="Edit" />
</td>
</tr>
</table>
</ItemTemplate>

<EditItemTemplate>
<table border="0" width="100%" CellPadding="0" CellSpacing="0"
style="margin:0">
<tr>
<td width="100%">
<asp:TextBox id="txtQuestion" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "Question") %>' />
</td>
<td width="30">
<asp:button Text="Update" runat="server" CommandName="Update" />
<asp:button Text="Cancel" runat="server" CommandName="Cancel" />
</td>
</tr>
</table>
</EditItemTemplate>
</asp:datalist>
************************************************** ******************************************

Thanks,

Tom
Nov 19 '05 #1
4 2096
I figured out what I did wrong here.

I forgot to do:

Dim oList as DataList = CType(S, DataList)
oList.EditItemIndex = e.Item.ItemIndex

But do I need to re-read the data and bind to the whole datalist again?

I have about 40 rows of data and want to change one row?

Thanks,

Tom

"tshad" <ts**********@ftsolutions.com> wrote in message
news:eD**************@TK2MSFTNGP12.phx.gbl...
I have a DataList that I have set up to allow editing. The edit button
does go to the subroutine defined by OnEditCommand. The problem is that it
doesn't change the fields to editing fields. The textbox doesn't show from
the edititemtemplate section. I don't get any errors.

Do I need to do something special to tell it to do this?

Here is the datalist:

************************************************** ******************************************
<asp:datalist id="DataList1"
runat="server"
Width="100%"
BorderWidth="0px"
OnEditCommand="DataListEdit"
OnUpdateCommand="DataListUpdate"
OnCancelCommand="DataListCancel"
footerstyle-horizontalalign="center"
CellPadding="0"
CellSpacing="0"
Border="0"
style="margin:0">
<AlternatingItemStyle cssClass=alternateRow ></AlternatingItemStyle>
<ItemTemplate>
<table border="0" width="100%" CellPadding="0" CellSpacing="0"
style="margin:0">
<tr>
<td width="100%">
<%# DataBinder.Eval(Container.DataItem, "Question") %>
</td>
<td width="30">
<asp:button Text="Edit" runat="server" CommandName="Edit" />
</td>
</tr>
</table>
</ItemTemplate>

<EditItemTemplate>
<table border="0" width="100%" CellPadding="0" CellSpacing="0"
style="margin:0">
<tr>
<td width="100%">
<asp:TextBox id="txtQuestion" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "Question") %>' />
</td>
<td width="30">
<asp:button Text="Update" runat="server" CommandName="Update" />
<asp:button Text="Cancel" runat="server" CommandName="Cancel" />
</td>
</tr>
</table>
</EditItemTemplate>
</asp:datalist>
************************************************** ******************************************

Thanks,

Tom

Nov 19 '05 #2
"tshad" <ts**********@ftsolutions.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I figured out what I did wrong here.

I forgot to do:

Dim oList as DataList = CType(S, DataList)
oList.EditItemIndex = e.Item.ItemIndex

But do I need to re-read the data and bind to the whole datalist again?

I have about 40 rows of data and want to change one row?


You have to rebind the DataList. Depending on your data, that may mean you
have to re-read the data. If you've got it stored in Session or Cache, then
you wouldn't necessarily have to re-read it.

John Saunders
Nov 19 '05 #3

"John Saunders" <johnwsaundersiii at hotmail.com> wrote in message
news:u%****************@TK2MSFTNGP12.phx.gbl...
"tshad" <ts**********@ftsolutions.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I figured out what I did wrong here.

I forgot to do:

Dim oList as DataList = CType(S, DataList)
oList.EditItemIndex = e.Item.ItemIndex

But do I need to re-read the data and bind to the whole datalist again?

I have about 40 rows of data and want to change one row?
You have to rebind the DataList. Depending on your data, that may mean you
have to re-read the data. If you've got it stored in Session or Cache,
then you wouldn't necessarily have to re-read it.


If I have nested DataGrids in my DataList, I assume these would have to be
rebound also?

Tom

John Saunders

Nov 19 '05 #4
"tshad" <ts**********@ftsolutions.com> wrote in message
news:eB**************@TK2MSFTNGP14.phx.gbl...

"John Saunders" <johnwsaundersiii at hotmail.com> wrote in message
news:u%****************@TK2MSFTNGP12.phx.gbl...
"tshad" <ts**********@ftsolutions.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I figured out what I did wrong here.

I forgot to do:

Dim oList as DataList = CType(S, DataList)
oList.EditItemIndex = e.Item.ItemIndex

But do I need to re-read the data and bind to the whole datalist again?

I have about 40 rows of data and want to change one row?


You have to rebind the DataList. Depending on your data, that may mean
you have to re-read the data. If you've got it stored in Session or
Cache, then you wouldn't necessarily have to re-read it.


If I have nested DataGrids in my DataList, I assume these would have to be
rebound also?


I suppose. I'm not sure.

John Saunders
Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Fabrizio | last post by:
Hi, I'm trying to create a page with a datalist that loads from a template the ItemTemplate, which contains a linkbutton that should have the commandname = "edit" But when I click on the link...
0
by: Alex | last post by:
Interested in more .NET stuff visit www.dedicatedsolutions.co.uk The DataList is not as powerful as the DataGrid. It requires more work from you since it has no default data presentation format....
8
by: Adam Billmeier | last post by:
Problem: I am trying to use FindControl to grab a dropdownlist that is in the EditItemTemplate of a Datalist and then Bind it to a dataset. I also then need to put the correct values in all of...
10
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
1
by: Chris Kettenbach | last post by:
Good Afternoon all, I have a datalist. When I switch in to edit mode, I need to hide a couple controls on the "ItemTemplate" and of course, when exiting Edit Mode, I will need to show these items...
3
by: Mirek Endys | last post by:
I have DataList as part of DataList item. DataList in DataList. The parent DataList working well including Edit command, that shows Edit template and correctly bind the data into edit template...
1
by: David | last post by:
Hi, This one appears a little strange to me. Here is the scenario. I load a datalist the first time a page is run. The page has a !IsPostback and the datalist gets loaded at this point. I...
3
by: Crazy Cat | last post by:
Hi all, I am developing an asp.net 2.0 application in Visual Studio 2005. On my page I have a simple datalist that is bound programmatically to a collection of simple objects. On this page I...
1
by: Arielle | last post by:
Background: I have a generated datalist to display information and I need to add the capability to have a button (Edit button) so that users can change the information. I'm sure once I figure it...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.