Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ListView Insert

Reply
Thread Tools

ListView Insert

 
 
David C
Guest
Posts: n/a
 
      10-06-2009
I have a ListView control that is bound to a DataSource and I need to
recognize when I am in Insert mode and use code to setup my DropDownList
control selections. I am using the code below in the ItemDataBound event to
identify Edit mode and it works great.

'Get the item and row objects.
Dim dataItem As ListViewDataItem = CType(e.Item, ListViewDataItem)
Dim rowView As DataRowView = CType(dataItem.DataItem, DataRowView)

'Verify there is an item being edited.
If lvIncExpTrans.EditIndex >= 0 Then

' Check for an item in edit mode.
If dataItem.DisplayIndex = lvIncExpTrans.EditIndex Then
'all my edit row setup code is here...

End If
End If


For identifying Insert mode I am using code below but it does not appear to
be working.

If dataItem.ItemType = ListViewItemType.InsertItem Then


What should I be checking to see that my ListView is in Insert mode.
Thanks.

David



 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      10-07-2009
On Oct 6, 9:08*pm, "David C" <(E-Mail Removed)> wrote:
> I have a ListView control that is bound to a DataSource and I need to
> recognize when I am in Insert mode and use code to setup my DropDownList
> control selections. *I am using the code below in the ItemDataBound event to
> identify Edit mode and it works great.
>
> * * * * 'Get the item and row objects.
> * * * * Dim dataItem As ListViewDataItem = CType(e.Item, ListViewDataItem)
> * * * * Dim rowView As DataRowView = CType(dataItem.DataItem, DataRowView)
>
> * * * * 'Verify there is an item being edited.
> * * * * If lvIncExpTrans.EditIndex >= 0 Then
>
> * * * * * * ' Check for an item in edit mode.
> * * * * * * If dataItem.DisplayIndex = lvIncExpTrans.EditIndex Then
> * 'all my edit row setup code is here...
>
> * * *End If
> *End If
>
> For identifying Insert mode I am using code below but it does not appear to
> be working.
>
> If dataItem.ItemType = ListViewItemType.InsertItem Then
>
> What should I be checking to see that my ListView is in Insert mode.
> Thanks.
>
> David


I think you can use OnItemCommand event

protected void lvItems_ItemCommand(object sender,
ListViewCommandEventArgs e)
{
if (e.CommandName == "Insert")
{
...
 
Reply With Quote
 
 
 
 
David C
Guest
Posts: n/a
 
      10-07-2009

"Alexey Smirnov" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
On Oct 6, 9:08 pm, "David C" <(E-Mail Removed)> wrote:
> I have a ListView control that is bound to a DataSource and I need to
> recognize when I am in Insert mode and use code to setup my DropDownList
> control selections. I am using the code below in the ItemDataBound event
> to
> identify Edit mode and it works great.
>
> 'Get the item and row objects.
> Dim dataItem As ListViewDataItem = CType(e.Item, ListViewDataItem)
> Dim rowView As DataRowView = CType(dataItem.DataItem, DataRowView)
>
> 'Verify there is an item being edited.
> If lvIncExpTrans.EditIndex >= 0 Then
>
> ' Check for an item in edit mode.
> If dataItem.DisplayIndex = lvIncExpTrans.EditIndex Then
> 'all my edit row setup code is here...
>
> End If
> End If
>
> For identifying Insert mode I am using code below but it does not appear
> to
> be working.
>
> If dataItem.ItemType = ListViewItemType.InsertItem Then
>
> What should I be checking to see that my ListView is in Insert mode.
> Thanks.
>
> David


I think you can use OnItemCommand event

protected void lvItems_ItemCommand(object sender,
ListViewCommandEventArgs e)
{
if (e.CommandName == "Insert")
{
...

Thanks, I will try that. Can I also set default values for that insert row
in there as well?

David


 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      10-07-2009
On Oct 7, 9:19*pm, "David C" <(E-Mail Removed)> wrote:
> "Alexey Smirnov" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
> On Oct 6, 9:08 pm, "David C" <(E-Mail Removed)> wrote:
>
>
>
>
>
> > I have a ListView control that is bound to a DataSource and I need to
> > recognize when I am in Insert mode and use code to setup my DropDownList
> > control selections. I am using the code below in the ItemDataBound event
> > to
> > identify Edit mode and it works great.

>
> > 'Get the item and row objects.
> > Dim dataItem As ListViewDataItem = CType(e.Item, ListViewDataItem)
> > Dim rowView As DataRowView = CType(dataItem.DataItem, DataRowView)

>
> > 'Verify there is an item being edited.
> > If lvIncExpTrans.EditIndex >= 0 Then

>
> > ' Check for an item in edit mode.
> > If dataItem.DisplayIndex = lvIncExpTrans.EditIndex Then
> > 'all my edit row setup code is here...

>
> > End If
> > End If

>
> > For identifying Insert mode I am using code below but it does not appear
> > to
> > be working.

>
> > If dataItem.ItemType = ListViewItemType.InsertItem Then

>
> > What should I be checking to see that my ListView is in Insert mode.
> > Thanks.

>
> > David

>
> I think you can use OnItemCommand event
>
> protected void lvItems_ItemCommand(object sender,
> ListViewCommandEventArgs e)
> {
> * * if (e.CommandName == "Insert")
> * * {
> * * * *...
>
> Thanks, I will try that. Can I also set default values for that insert row
> in there as well?
>
> David- Hide quoted text -
>
> - Show quoted text -


ok, I think I got it now, please follow the following page

http://forums.asp.net/p/1361580/2819708.aspx

they suggest to check the InsertItemPosition property as follows:

protected void lvwComputerGroups_DataBound(object sender, EventArgs e)
{
if (lvwComputerGroups.InsertItemPosition !=
InsertItemPosition.None)
{
....FindControl("...");


}
}

Let me know if it works
 
Reply With Quote
 
David C
Guest
Posts: n/a
 
      10-11-2009

"Alexey Smirnov" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
On Oct 7, 9:19 pm, "David C" <(E-Mail Removed)> wrote:
> "Alexey Smirnov" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
> On Oct 6, 9:08 pm, "David C" <(E-Mail Removed)> wrote:
>
>
>
>
>
> > I have a ListView control that is bound to a DataSource and I need to
> > recognize when I am in Insert mode and use code to setup my DropDownList
> > control selections. I am using the code below in the ItemDataBound event
> > to
> > identify Edit mode and it works great.

>
> > 'Get the item and row objects.
> > Dim dataItem As ListViewDataItem = CType(e.Item, ListViewDataItem)
> > Dim rowView As DataRowView = CType(dataItem.DataItem, DataRowView)

>
> > 'Verify there is an item being edited.
> > If lvIncExpTrans.EditIndex >= 0 Then

>
> > ' Check for an item in edit mode.
> > If dataItem.DisplayIndex = lvIncExpTrans.EditIndex Then
> > 'all my edit row setup code is here...

>
> > End If
> > End If

>
> > For identifying Insert mode I am using code below but it does not appear
> > to
> > be working.

>
> > If dataItem.ItemType = ListViewItemType.InsertItem Then

>
> > What should I be checking to see that my ListView is in Insert mode.
> > Thanks.

>
> > David

>
> I think you can use OnItemCommand event
>
> protected void lvItems_ItemCommand(object sender,
> ListViewCommandEventArgs e)
> {
> if (e.CommandName == "Insert")
> {
> ...
>
> Thanks, I will try that. Can I also set default values for that insert row
> in there as well?
>
> David- Hide quoted text -
>
> - Show quoted text -


ok, I think I got it now, please follow the following page

http://forums.asp.net/p/1361580/2819708.aspx

they suggest to check the InsertItemPosition property as follows:

protected void lvwComputerGroups_DataBound(object sender, EventArgs e)
{
if (lvwComputerGroups.InsertItemPosition !=
InsertItemPosition.None)
{
....FindControl("...");


}
}

Let me know if it works

Yes, that worked. Thank you.

David


 
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
asp.net ListView control - Configure ListView option missing? . ASP .Net 0 07-24-2010 12:20 AM
Insert Button. ListView or GridView. Is this possible? shapper ASP .Net 4 11-20-2008 09:39 AM
LinqDataSource/ ListView - Inserts Returning No Values To Insert Philip ASP .Net 2 07-23-2008 12:49 AM
Update and Insert problems in ListView shapper ASP .Net 1 02-12-2008 12:46 AM
ListView ... Update and Insert shapper ASP .Net 0 02-08-2008 04:02 PM



Advertisments