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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:03:53+00:00 2026-05-21T02:03:53+00:00

I have a gridview, and it has an author column. I want to display

  • 0

I have a gridview, and it has an author column. I want to display the author name as a hyperlink, so when the user clicks on it he gets redirected to the author page. But when the user wishes to edit the author for current product, he should see a dropdownlist. I am trying to implement it using a template field:

<asp:TemplateField HeaderText="автор">
        <ItemTemplate>
            <asp:HyperLink ID="HyperLink1" runat="server" NavigateURL='<%# "~/CMS/AuthorPage.aspx?a="+ Eval("AuthorID")%>' Text='<%#Eval("AuthorID")%>' />                                    
        </ItemTemplate>
        <EditItemTemplate>
                <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource3" 
        DataTextField="Name" DataValueField="ID"/>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" 
        ConnectionString="<%$ ConnectionStrings:aspnetdbConnectionString1 %>" 
        SelectCommand="SELECT [ID], [Name] FROM [Authors] ORDER BY [Name]"></asp:SqlDataSource>                
</EditItemTemplate>
</asp:TemplateField>       

But how do I specify the selected value, and how do I store the selected value after edit?

  • 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-05-21T02:03:53+00:00Added an answer on May 21, 2026 at 2:03 am

    You need to do it in RowDataBound event of GridView and then in RowUpdating event you can get the selected value

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        DropDownList DropDownList1 = (DropDownList)e.Row.FindControl("DropDownList1");
        DropDownList1.SelectedValue = "SomeID";
    }
    

    and get the selected value by

    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        DropDownList DropDownList1 = (DropDownList)this.GridView1.Rows[e.RowIndex].FindControl("DropDownList1");
        string value = DropDownList1.SelectedValue;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a GridView on a .aspx page with a hidden column which has
I have a GridView which has EditButton and DeleteButton enabled. When the user clicks
Suppose I have a GridView on the page. GridView has edit column enabled and
I have a GridView. My GridView has a column that is contains an Options
I have a user control that contains a GridView. The GridView has both a
For example, Lets say that I have a gridview column which has important controls,
I have a gridview inside an updatepanel. It has a TemplateField column with radiobutton:
I have a gridview with a template field that has a HyperLink: <asp:TemplateField ItemStyle-Width=12%
I have a gridview and it has some columns . For example: Name|Age|Birthday How
I have a gridview that has a usercontrol in a template column on each

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.