Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Insert Button. ListView or GridView. Is this possible?

Reply
Thread Tools

Insert Button. ListView or GridView. Is this possible?

 
 
shapper
Guest
Posts: n/a
 
      12-04-2007
Hello,

I am working with a ListView but I suppose that with a GridView might
be the same.

Instead of having an Insert Button on each GridView row I would like
to have only one Insert button, for example, in the GridView footer.

When this button is clicked it should put the GridView in Insert Mode
and the EditTemplate should be showed, maybe (?), in the last GridView
row.

Do you understand what I mean?

Any idea how to do this?

Thanks,

Miguel
 
Reply With Quote
 
 
 
 
shapper
Guest
Posts: n/a
 
      12-05-2007
On Dec 4, 7:37 pm, shapper <(E-Mail Removed)> wrote:
> Hello,
>
> I am working with a ListView but I suppose that with a GridView might
> be the same.
>
> Instead of having an Insert Button on each GridView row I would like
> to have only one Insert button, for example, in the GridView footer.
>
> When this button is clicked it should put the GridView in Insert Mode
> and the EditTemplate should be showed, maybe (?), in the last GridView
> row.
>
> Do you understand what I mean?
>
> Any idea how to do this?
>
> Thanks,
>
> Miguel


Please, what I need is something like what you find in the following
ComponentArt Grid:

http://www.componentart.com/webui/de.../WebForm1.aspx

See the button "Add Row" on bottom.
When this button is clicked the Grid goes to Edit mode and the data is
inserted in a new row after the last row.

This is what I need to do.

Any idea?

Thanks,

Miguel
 
Reply With Quote
 
 
 
 
Manuel Ricca
Guest
Posts: n/a
 
      12-05-2007
Hello Miguel,

Check out this URL which helped me solve this problem:
http://www.koffeekoder.com/ArticleDetails.aspx?id=139

Basically you just have to edit the footer template for the column
where you want and put a button in it. Then set the CommandName for
the button and in the RowCommand event handler find out if this is the
command that was fired. Here you insert your item into the datasource
and the gridview will be updated reflecting these changes.

Here is a snippet from my own app. In this app I have a GridView with
3 columns, and in the footer I placed 2 textboxes and an "Add" button.
As you can see below, the textboxes are named txtNewURL and
txtNewURLNPages. Then I'm using an ObjectDataSource with 2 insert
parameters (I put the code below too).



ServiceConfiguration.aspx ("Actions" column in the GridView)

<asp:TemplateField HeaderText="Actions">
....
<FooterTemplate>
<asp:Button id="cmdAddURL" runat="server" Text="Add"
__designer:wfdid="w4" CommandName="AddURL"></asp:Button>
</FooterTemplate>
....
</asp:TemplateField>


ServiceConfiguration.aspx.cs:

protected void gridTargetURLs_RowCommand(object sender,
GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("AddURL"))
{
string url =
((TextBox)gridTargetURLs.FooterRow.FindControl("tx tNewURL")).Text;
string szNumberOfPages =
((TextBox)gridTargetURLs.FooterRow.FindControl("tx tNewURLNPages")).Text;
DS_Urls.InsertParameters["url"].DefaultValue = url;
DS_Urls.InsertParameters["numberOfPages"].DefaultValue =
szNumberOfPages;
DS_Urls.Insert();
}
}


Now the ObjectDataSource stuff (you could use any other data source
though):

ServiceConfiguration.aspx:


<asp:ObjectDataSource
ID="DS_Urls" runat="server" DeleteMethod="ODS_TargetURLDelete"
InsertMethod="ODS_TargetURLInsert"
OnObjectCreating="DS_Urls_ObjectCreating"
SelectMethod="ODS_TargetURLSelect" TypeName="CWService"
UpdateMethod="ODS_TargetURLUpdate">
<InsertParameters>
<asparameter
Name="url" Type="String" />
<asparameter
Name="numberOfPages" Type="String" />
</
InsertParameters>
<DeleteParameters>
<asparameter
Name="id" Type="Int32" />
</
DeleteParameters>
<UpdateParameters>
<asparameter
Name="id" Type="Int32" />
<asparameter
Name="url" Type="String" />
<asparameter
Name="numberOfPages" Type="String" />
</
UpdateParameters>
</
asp:ObjectDataSource>


ServiceConfiguration.aspx.cs:

public void ODS_TargetURLInsert(string url, string numberOfPages)
{
targetURLs.Add(new CWTargetURL(url,
int.Parse(numberOfPages)));
}



Hope this helps!

Manuel Ricca


On Dec 5, 1:31 am, shapper <(E-Mail Removed)> wrote:
> On Dec 4, 7:37 pm, shapper <(E-Mail Removed)> wrote:
>
>
>
>
>
> > Hello,

>
> > I am working with a ListView but I suppose that with a GridView might
> > be the same.

>
> > Instead of having an Insert Button on each GridView row I would like
> > to have only one Insert button, for example, in the GridView footer.

>
> > When this button is clicked it should put the GridView in Insert Mode
> > and the EditTemplate should be showed, maybe (?), in the last GridView
> > row.

>
> > Do you understand what I mean?

>
> > Any idea how to do this?

>
> > Thanks,

>
> > Miguel

>
> Please, what I need is something like what you find in the following
> ComponentArt Grid:
>
> http://www.componentart.com/webui/de...pecific/grid/f...
>
> See the button "Add Row" on bottom.
> When this button is clicked the Grid goes to Edit mode and the data is
> inserted in a new row after the last row.
>
> This is what I need to do.
>
> Any idea?
>
> Thanks,
>
> Miguel- Hide quoted text -
>
> - Show quoted text -


 
Reply With Quote
 
bartekm bartekm is offline
Junior Member
Join Date: Aug 2008
Posts: 7
 
      08-19-2008
Hi,

I definately recommend the Listview for this one.

There is a tutorial on how to do what you want here:

http://blog.evonet.com.au/post/2008/...ws-footer.aspx

Cheers,
Bartek
 
Reply With Quote
 
David David is offline
Junior Member
Join Date: Nov 2008
Posts: 1
 
      11-20-2008
Could you pls suggest how to include Insert,update and delete in ListView using the ObjectDataSource???
 
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
DropDownList in listview insert Template binding problem WebBuilder451 ASP .Net 0 11-07-2008 11:11 PM
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