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 8187549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:35:50+00:00 2026-06-07T02:35:50+00:00

I have a GridView control which shows a list of all employees. When user

  • 0

I have a GridView control which shows a list of all employees. When user selects any employee from this list, the record is shown on a Web Form with all input controls pre-filled with the values.

I want to know any good approach to do this. Should I bind all input controls to any SqlDataSource or should I re-populate all input controls by picking values from the DataSet.

  • 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-07T02:35:51+00:00Added an answer on June 7, 2026 at 2:35 am

    First you add the select button on your GridView as:

    <asp:ButtonField Text="Select" CommandName="ViewMe" ButtonType="Button" />
    

    then you add the OnRowCommand="RowCommand" property on GridView to call this function when the button is clicked and on code behind the function:

    protected void RowCommand(object sender, GridViewCommandEventArgs e)
    {
        // if the ViewMe command is fired
        if (e.CommandName == "ViewMe")
        {
            // go to find the index on the grid view
            int iTheIndexNow;
            if (int.TryParse(e.CommandArgument.ToString(), out iTheIndexNow))
            {
                // Set and highlight the selected
                TheGridView.SelectedIndex = iTheIndexNow;
    
                // do we have the table data id ?
                if (TheGridView.SelectedValue != null)
                {
                    // now load the controls data using this id
                    LoadValuesFromDatabaseToControls(TheGridView.SelectedValue);
                }    
            }
        }
    }
    

    I prefer this way of command button because you can add more commands than the select, or edit, even the delete or copy… the just index change can be done for any reason (eg by changing page) and is also need again the select.

    I use the subsonic 2 DAL for loading the data from the database. A sample code from my programs is:

        void LoadValuesFromDatabaseToControls(string editID)
        {
            // Load it from database
            AthUserMaiListName OneRow = new AthUserMaiListName(editID);
    
            if (OneRow.IsNotExist)
            {
                // a custom control that show messages on top.
                uResult.addMsg("Fail to load id " + editID, MsgType.error);
                // close the view of the controls
                dbViewPanel.Visible = false;
            }
            else // else we have the data and go for show them
            {
              // show this panel that contains the controls.
              dbViewPanel.Visible = true;
    
              // I keep my current edit id
              lblID.Text = editID;
    
              // just be sure that the select exist on DrowDownList
              MyUtils.SelectDropDownList(ddlEventType, OneRow.CAddedFrom);
    
              txtEmail.Text = OneRow.CEmail;
              txtFirstName.Text = OneRow.CFirstName;
              txtLastName.Text = OneRow.CLastName;
              txtInsideTitle.Text = OneRow.CInsideTitle;
              txtCompanyName.Text = OneRow.CCompanyName;        
    
              txtCreated.Text = DateTimeRender(OneRow.CreatedOn);
              txtModified.Text = DateTimeRender(OneRow.ModifiedOn);
            }
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a GridView inside of a User Control populated from a List of
I have standard .net 2.0 gridview control from which i want to get row
I have a GridView control bound to an ObjectDataSource which returns a list of
Have a gridview control which will show X amount of rows. I want to
Using asp.net 3.5 Gridview control, visual studio 2008. I have played with all the
I've got a GridView control which is bound to a List of custom objects.
I have a Windows Forms user control which consists of several controls. Among others
A typical situation: In my GridView control, I have a Footer row which contains
I have a gridview control in my c# program which currently has 12 columns
I have a gridview which contains a textbox control. I need to show the

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.