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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:45:57+00:00 2026-05-27T23:45:57+00:00

I have a Datagrid which looks as under <asp:GridView ID=dgTask runat=server Width=100% AutoGenerateColumns=False> <Columns>

  • 0

I have a Datagrid which looks as under

<asp:GridView ID="dgTask" runat="server" Width="100%" AutoGenerateColumns="False">
    <Columns>
        <asp:BoundField DataField="TaskID" HeaderText="TaskID" ItemStyle-Width="1%" />
        <asp:BoundField DataField="TaskName" HeaderText="Task Name" ItemStyle-HorizontalAlign="left"
            ItemStyle-Width="10%" />
        <asp:BoundField DataField="PriorityName" HeaderText="Priority" ItemStyle-HorizontalAlign="center"
            ItemStyle-Width="10%" />
        <asp:BoundField DataField="StatusName" HeaderText="Status" ItemStyle-HorizontalAlign="center"
            ItemStyle-Width="10%" />
        <asp:TemplateField HeaderText="Edit Task" ItemStyle-Width="10%">
            <ItemTemplate>
                <asp:LinkButton ID="lnkBtnEdit" runat="Server" Text="Edit" />
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

As can be figure out that, there is a link button control inside the grid. Our requirement is that, when the user double click on this link button, then for that
row it should change to a dropdown list.

How to do so? Googling does not help much.

Please help

Data Population in grid

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        var records = GetData();
        dgTask.DataSource = records;
        dgTask.DataBind();
    }

    private List<TaskEntity> GetData()
    {
        List<TaskEntity> lstTaskEntity = new List<TaskEntity>();
        Enumerable.Range(1, 10)
            .ToList()
            .ForEach(
                        i => lstTaskEntity.Add(new TaskEntity
                        {
                            TaskID = i
                         ,
                            TaskName = string.Concat("TaskName", i)
                         ,
                            PriorityName = string.Concat("PriorityName", i)
                         ,
                            StatusName = string.Concat("StatusName", i)
                        }));
        return lstTaskEntity;
    }
}

public class TaskEntity
{
    public int TaskID { get; set; }
    public string TaskName { get; set; }  
    public string PriorityName { get; set; }  
    public string StatusName { get; set; }   
}

Thanks in advance

  • 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-27T23:45:57+00:00Added an answer on May 27, 2026 at 11:45 pm
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script language="javascript" type="text/javascript">
            function Test(object) {
    
                var splitComponents = object.split(",");
                var ddlId = splitComponents[0];
                var lnlBtnId = splitComponents[1];
    
                document.getElementById(ddlId).style.display = "inline";
                document.getElementById(lnlBtnId).style.display = "none";
    
                return false;
    
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:GridView ID="dgTask" runat="server" Width="100%" 
                AutoGenerateColumns="False" onrowdatabound="dgTask_RowDataBound" 
                >
                <Columns>
                    <asp:BoundField DataField="TaskID" HeaderText="TaskID" ItemStyle-Width="1%" />
                    <asp:BoundField DataField="TaskName" HeaderText="Task Name" ItemStyle-HorizontalAlign="left"
                        ItemStyle-Width="10%" />
                    <asp:BoundField DataField="PriorityName" HeaderText="Priority" ItemStyle-HorizontalAlign="center"
                        ItemStyle-Width="10%" />
                    <asp:BoundField DataField="StatusName" HeaderText="Status" ItemStyle-HorizontalAlign="center"
                        ItemStyle-Width="10%" />
                    <asp:TemplateField HeaderText="Edit Task" ItemStyle-Width="10%">
                        <ItemTemplate>
                            <asp:LinkButton ID="lnkBtnEdit" runat="Server" Text="Edit" CommandArgument ='<%# Eval("TaskID") %>' OnClick="Button2_Click"/> 
                            <asp:DropDownList ID = "ddlDropDown" runat="server"></asp:DropDownList>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
        </div>
        </form>
    </body>
    </html>
    

    RowDataBound

    protected void dgTask_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                LinkButton btn = (LinkButton)e.Row.Cells[4].FindControl("lnkBtnEdit");
    
                DropDownList ddl = (DropDownList)e.Row.Cells[4].FindControl("ddlDropDown");
                ddl.DataSource = //give datasource;
                ddl.DataBind();
    
                ddl.Attributes.Add("style", "display:none");
                btn.Attributes.Add("onclick", "return Test('" + ddl.ClientID + "," + btn.ClientID + "');");
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data grid that looks like this <tk:DataGrid ItemsSource={Binding Parents} AutoGenerateColumns=False> <tk:DataGrid.Columns>
We have a Flex DataGrid with 3 columns of which one of them has
I have a datagrid which is populated with CSV data when the user drag/drops
I have a DataGrid which I am binding to a PagedCollectionView which is grouped
I have a DataGrid which is being bound dynamically to a database query. The
I have a DataGrid which i am using on the page alogn with 4
Scenario I have a DevExpress DataGrid which is bound to a DataSet in C#.
I have a dataGrid(not dataGridView) in which i need to add Checkbox dynamically at
I have I datagrid, on which I want to select multiple rows on a
I have a Silverlight DataGrid that contains a single template column which displays a

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.