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

  • SEARCH
  • Home
  • 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 9243609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:50:37+00:00 2026-06-18T08:50:37+00:00

I have gridview and I added edit function to update grid content as when

  • 0

I have gridview and I added edit function to update grid content as when user click on edit button panel displayed with fields have grid content and user can edit on the data one of these data drop down which have location data . but when I click on edit button all fields have grid content but the DDL have the first item at first time and when I click the edit again DDL have the right item . So what it the problem?

 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "editrow")
    {
        GridViewRow row = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer);

        TextBox name = row.FindControl("Lbl_Name") as TextBox;

        TextBox address = row.FindControl("Lbl_Address") as TextBox;
        Label mobile = row.FindControl("Lbl_Mobile") as Label;
        Label tele = row.FindControl("Lbl_Tele") as Label;

        Label area = row.FindControl("Lbl_Area_ID") as Label;
        Label location = row.FindControl("Lbl_Loc_ID") as Label;
        Label category = row.FindControl("Lbl_Cat_ID") as Label;


        txt_adr.Text = address.Text;
        txt_mobile.Text = mobile.Text;
        txt_name.Text = name.Text;
        txt_tele.Text = tele.Text;
        ddl_category.SelectedValue = category.Text;
        //the problem here on ddloc
        ddloc.SelectedValue = location.Text;

        DDL_AREA.SelectedValue = area.Text;




    }
}
  • 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-18T08:50:38+00:00Added an answer on June 18, 2026 at 8:50 am

    Instead of

    ddloc.SelectedValue = location.Text;
    

    use

    ddloc.Selecteditem.Text = location.Text;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a grid view which gives project info.I have added edit button. My
I have a gridview that displays items details, I added two template fields one
I have a gridview with a delete button. I've added a messagebox with an
I have a grid view, where user can add a new row. On the
I have a GridView inside an update panel, and a AsyncFileUpload (outside the Update
I have one GridView and one Add Button. If I click the Add button,
I have a gridview and I have a button on it.I want, if the
I have a Gridview which is connected with SqlDataSource for Data. I have Edit
I have gridview, it's datasource is list<string> and I added one checkbox column to
I have a SQLite database that is displayed in a data grid view in

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.