Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > edit multiple records in a gridview with one postback

Reply
Thread Tools

edit multiple records in a gridview with one postback

 
 
archuleta37
Guest
Posts: n/a
 
      02-09-2007
I've got a asp.net 2.0 gridview with a list of orders. I want to add a column
with a checkbox (simple enough) and make it so that when I click a submit
button, the postback sets the status on each of the records with a checkbox
so that they are completed.

So in my gridview, I have the following attribute:
DataKeyNames="order_id"

and the following code for the status:
<asp:TemplateField HeaderText="Item Status" SortExpression="status_name">
<EditItemTemplate>
<aspropDownList ID="ddStatus" runat="server"
DataSourceID="dsStatus"
DataTextField="status_name"
DataValueField="status_id"
SelectedValue='<%# Bind("order_status_id") %>'>
</aspropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblStatus" runat="server" Text='<%#
Bind("status_name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>

and have added a checkbox column:
<asp:CheckBoxField HeaderText="Close" />

and outside the gridview I added:
<asp:LinkButton ID="btnCloseItems" runat="server"
CommandName="closeSelected">Close Selected</asp:LinkButton>

then in my page load method, I have:

if (IsPostBack)
{

}

but where do I go from here? I feel comfortable writing a method that
changes the status for the records, but how do I go about looping through the
records in the postback and identifying the value of the checkbox and
order_id? Is there a standard asp.net way of doing what I'm trying to do, or
is writing code to handle this the best approach? In any case, any help to
accomplish my goal would be much appreciated.

Marc


 
Reply With Quote
 
 
 
 
Bruno Alexandre
Guest
Posts: n/a
 
      02-14-2007
all you need to do is:

read this tutorial

http://www.gridviewguy.com/ArticleDe...?articleID=219


Bruno Alexandre
Stroby, Danmark

"a Portuguese in Denmark"


"archuleta37" <> wrote in message
news:01B5970F-06BB-4074-A8B4-...
> I've got a asp.net 2.0 gridview with a list of orders. I want to add a
> column
> with a checkbox (simple enough) and make it so that when I click a submit
> button, the postback sets the status on each of the records with a
> checkbox
> so that they are completed.
>
> So in my gridview, I have the following attribute:
> DataKeyNames="order_id"
>
> and the following code for the status:
> <asp:TemplateField HeaderText="Item Status" SortExpression="status_name">
> <EditItemTemplate>
> <aspropDownList ID="ddStatus" runat="server"
> DataSourceID="dsStatus"
> DataTextField="status_name"
> DataValueField="status_id"
> SelectedValue='<%# Bind("order_status_id") %>'>
> </aspropDownList>
> </EditItemTemplate>
> <ItemTemplate>
> <asp:Label ID="lblStatus" runat="server" Text='<%#
> Bind("status_name") %>'></asp:Label>
> </ItemTemplate>
> </asp:TemplateField>
>
> and have added a checkbox column:
> <asp:CheckBoxField HeaderText="Close" />
>
> and outside the gridview I added:
> <asp:LinkButton ID="btnCloseItems" runat="server"
> CommandName="closeSelected">Close Selected</asp:LinkButton>
>
> then in my page load method, I have:
>
> if (IsPostBack)
> {
>
> }
>
> but where do I go from here? I feel comfortable writing a method that
> changes the status for the records, but how do I go about looping through
> the
> records in the postback and identifying the value of the checkbox and
> order_id? Is there a standard asp.net way of doing what I'm trying to do,
> or
> is writing code to handle this the best approach? In any case, any help to
> accomplish my goal would be much appreciated.
>
> Marc
>
>


 
Reply With Quote
 
 
 
 
archuleta37
Guest
Posts: n/a
 
      02-14-2007
Oh Wow!
They make it so easy!

Thanks Bruno, I'll put this to good use.
Marc



"Bruno Alexandre" wrote:

> all you need to do is:
>
> read this tutorial
>
> http://www.gridviewguy.com/ArticleDe...?articleID=219
>
>
> Bruno Alexandre
> Stroby, Danmark
>
> "a Portuguese in Denmark"
>
>
> "archuleta37" <> wrote in message
> news:01B5970F-06BB-4074-A8B4-...
> > I've got a asp.net 2.0 gridview with a list of orders. I want to add a
> > column
> > with a checkbox (simple enough) and make it so that when I click a submit
> > button, the postback sets the status on each of the records with a
> > checkbox
> > so that they are completed.
> >
> > So in my gridview, I have the following attribute:
> > DataKeyNames="order_id"
> >
> > and the following code for the status:
> > <asp:TemplateField HeaderText="Item Status" SortExpression="status_name">
> > <EditItemTemplate>
> > <aspropDownList ID="ddStatus" runat="server"
> > DataSourceID="dsStatus"
> > DataTextField="status_name"
> > DataValueField="status_id"
> > SelectedValue='<%# Bind("order_status_id") %>'>
> > </aspropDownList>
> > </EditItemTemplate>
> > <ItemTemplate>
> > <asp:Label ID="lblStatus" runat="server" Text='<%#
> > Bind("status_name") %>'></asp:Label>
> > </ItemTemplate>
> > </asp:TemplateField>
> >
> > and have added a checkbox column:
> > <asp:CheckBoxField HeaderText="Close" />
> >
> > and outside the gridview I added:
> > <asp:LinkButton ID="btnCloseItems" runat="server"
> > CommandName="closeSelected">Close Selected</asp:LinkButton>
> >
> > then in my page load method, I have:
> >
> > if (IsPostBack)
> > {
> >
> > }
> >
> > but where do I go from here? I feel comfortable writing a method that
> > changes the status for the records, but how do I go about looping through
> > the
> > records in the postback and identifying the value of the checkbox and
> > order_id? Is there a standard asp.net way of doing what I'm trying to do,
> > or
> > is writing code to handle this the best approach? In any case, any help to
> > accomplish my goal would be much appreciated.
> >
> > Marc
> >
> >

>

 
Reply With Quote
 
archuleta37
Guest
Posts: n/a
 
      03-02-2007
Hey Bruno,

I ran into another approach to this that I thought I'd share:

article:
http://blogs.msdn.com/mattdotson/articles/490868.aspx
code:
http://www.codeplex.com/ASPNetRealWorldContr


"Bruno Alexandre" wrote:

> all you need to do is:
>
> read this tutorial
>
> http://www.gridviewguy.com/ArticleDe...?articleID=219
>
>
> Bruno Alexandre
> Stroby, Danmark
>
> "a Portuguese in Denmark"
>
>
> "archuleta37" <> wrote in message
> news:01B5970F-06BB-4074-A8B4-...
> > I've got a asp.net 2.0 gridview with a list of orders. I want to add a
> > column
> > with a checkbox (simple enough) and make it so that when I click a submit
> > button, the postback sets the status on each of the records with a
> > checkbox
> > so that they are completed.
> >
> > So in my gridview, I have the following attribute:
> > DataKeyNames="order_id"
> >
> > and the following code for the status:
> > <asp:TemplateField HeaderText="Item Status" SortExpression="status_name">
> > <EditItemTemplate>
> > <aspropDownList ID="ddStatus" runat="server"
> > DataSourceID="dsStatus"
> > DataTextField="status_name"
> > DataValueField="status_id"
> > SelectedValue='<%# Bind("order_status_id") %>'>
> > </aspropDownList>
> > </EditItemTemplate>
> > <ItemTemplate>
> > <asp:Label ID="lblStatus" runat="server" Text='<%#
> > Bind("status_name") %>'></asp:Label>
> > </ItemTemplate>
> > </asp:TemplateField>
> >
> > and have added a checkbox column:
> > <asp:CheckBoxField HeaderText="Close" />
> >
> > and outside the gridview I added:
> > <asp:LinkButton ID="btnCloseItems" runat="server"
> > CommandName="closeSelected">Close Selected</asp:LinkButton>
> >
> > then in my page load method, I have:
> >
> > if (IsPostBack)
> > {
> >
> > }
> >
> > but where do I go from here? I feel comfortable writing a method that
> > changes the status for the records, but how do I go about looping through
> > the
> > records in the postback and identifying the value of the checkbox and
> > order_id? Is there a standard asp.net way of doing what I'm trying to do,
> > or
> > is writing code to handle this the best approach? In any case, any help to
> > accomplish my goal would be much appreciated.
> >
> > Marc
> >
> >

>

 
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
cannot delete or edit inserted records ( via detailsview) in gridview Marc ASP .Net 1 07-31-2006 06:05 PM
cannot delete or edit inserted records ( via detailsview) in gridview Marc ASP .Net Web Controls 1 07-31-2006 06:05 PM
How to display/edit/update/insert new records (non-key columns) in a dynamic gridview? loga123 ASP .Net 0 05-23-2006 08:24 AM
Snapshot restraint - edit, edit, edit Alan Browne Digital Photography 24 05-10-2005 10:15 PM
Snapshot restraint - edit, edit, edit Patrick Digital Photography 0 05-06-2005 10:53 PM



Advertisments