Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8015465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:15:56+00:00 2026-06-04T20:15:56+00:00

I have a gridView in ConsumerList page. When Edit button is clicked (in each

  • 0

I have a gridView in ConsumerList page. When Edit button is clicked (in each row), it is navigated to a EditConsumer page. In the EditConsumer page, I need to get the values of the selected row using Page.PreviousPage. How to get these values?

    public void Consumer_RowCommand(Object sender, GridViewCommandEventArgs e)
    {

        if (e.CommandName == "CustomEdit")
        {
            int rowIndex = Convert.ToInt32(e.CommandArgument);
            string consumerID = grdConsumers.Rows[rowIndex].Cells[1].Text;
            string consumerName = grdConsumers.Rows[rowIndex].Cells[2].Text;
            string consumerUrl = grdConsumers.Rows[rowIndex].Cells[3].Text;
            string consumerStatus = grdConsumers.Rows[rowIndex].Cells[4].Text;

            Response.Redirect("EditConsumer.aspx?RowIndex=" + rowIndex);
        }
    }

MARKUP

  <asp:GridView ID="grdConsumers" runat="server" AutoGenerateColumns="False" CssClass="resultGridTable"
                GridLines="None" EnableViewState="True" AllowSorting="True" OnSorting="Consumers_Sorting" OnRowCommand="Consumer_RowCommand">
                <AlternatingRowStyle BackColor="#E5E5E5" />
                <Columns>

                   <asp:TemplateField HeaderText="Action">
                        <ItemTemplate>

                             <asp:Button ID="btnView" runat="server" CssClass="actionButtonView"
                                  Text="VIEW" Style="width: 40px" BackColor="Orange"
                                  Font-Bold="True" ForeColor="White" /> 

                             <asp:Button ID="btnEdit" runat="server" CommandName="CustomEdit" CommandArgument="<%# ((GridViewRow)Container).RowIndex %>"
                              CssClass="actionButtonEdit"
                                  Text="EDIT" Style="width: 35px" BackColor="Orange"
                                  Font-Bold="True" ForeColor="White" /> 

                             <asp:Button ID="btnDelete" runat="server" CssClass="actionButtonDelete"
                                  Text="DELETE" Style="width: 55px" BackColor="Orange"
                                  Font-Bold="True" ForeColor="White" />

                             <asp:Button ID="btnPing" runat="server" CssClass="actionButtonPing"
                                  Text="PING" Style="width: 35px" BackColor="Orange"
                                  Font-Bold="True" ForeColor="White" />

                         </ItemTemplate>
                    </asp:TemplateField>

                    <asp:BoundField HeaderText="Consumer ID" DataField="ConsumerID" SortExpression="ConsumerID"></asp:BoundField>
                    <asp:BoundField HeaderText="Consumer Name" DataField="ConsumerName" SortExpression="ConsumerName"></asp:BoundField>
                    <asp:BoundField HeaderText="Consumer URL" DataField="ConsumerURL" SortExpression="ConsumerURL"></asp:BoundField>
                    <asp:BoundField HeaderText="Status" DataField="Status" SortExpression="Status"></asp:BoundField>



                </Columns>
            </asp:GridView>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T20:15:57+00:00Added an answer on June 4, 2026 at 8:15 pm

    Note: PreviousPage is only != null with cross page posting, Response.Redirect will not work. So you could for example use Server.Transfer.

    You could provide a public property SelectedConsumer that returns a custom object of the curerently selected row in the GridView.

    public Consumer SelectedConsumer
    {
        get {
            if (grdConsumers.SelectedRow == null)
                return null;
    
            var c = new Consumer();
            c.consumerID = grdConsumers.SelectedRow.Cells[1].Text;
            c.consumerName = grdConsumers.SelectedRow.Cells[2].Text;
            c.consumerUrl = grdConsumers.SelectedRow.Cells[3].Text;
            c.consumerStatus = grdConsumers.SelectedRow.Cells[4].Text;
    
            return c;
        }
    }
    

    Now you only have to cast the PreviousPage property to the correct page type:

    var consumerList = (ConsumerList)Page.PreviousPage;
    var selectedConsumer = consumerList.SelectedConsumer;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have asp.net's .aspx page. that have GridView let say GridViewParent and Each row
I have GridView with CheckBox in it's header and another one in each row:
I have GridView and I need HTML ENCODE all values being update using Event
i have GridView with each Grid as a simple TextView. i need a scrollbar
I have a GridView, which features a a checkbox on each row (in a
I have GridView which I can select a row. I then have a button
I have gridview which contains 60 rows and each row has 4 radiobutton option
Greetings, In my current project, I have gridview, search button, text box for search,
I have gridview in my asp.net page which is bound to sqldatasource. when i
I am using a GridView within an updatepanel. I have gridview generated edit and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.