Link to home
Start Free TrialLog in
Avatar of snapsy
snapsy

asked on

Add Link Button controls to GridView control and attach event handler

Hi there, I am kind of new to the ASP.NET.
1) I am trying to add Link Button controls to the GridView control for each row programmatically
2) Create an event handler for the link buttons
3) For each link button, pass some kind of value ( like an ID ) to the "Click" event handler

Please help!!!

public partial class UserList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string userSQL =
          "SELECT [ENTUserAccountId] , [FirstName] , [LastName] FROM [ENTUserAccount] ORDER BY [LastName]";
        try
        {
            //  Create new DataAdapter to connect to Users
            //  table in HCC_Database database

            string DBConn = DBCommon.GetConnectionString("HCC_Connection");
            using (SqlDataAdapter adapter = new SqlDataAdapter(userSQL, DBCommon.GetConnectionString("HCC_Connection")))
            {

                DataSet ds = new DataSet();
                adapter.Fill(ds, "UserList");

                DataTable dp = ds.Tables["UserList"];
                this.GridUsers.Visible = true;

                GridUsers.DataSource = dp;
                GridUsers.DataBind();

                GridUsers.HeaderRow.Cells[0].Text = "User ID";
                GridUsers.HeaderRow.Cells[1].Text = "First Name";
                GridUsers.HeaderRow.Cells[2].Text = "Last Name";

            }

        }
        catch (Exception ex)
        {

        }
    }


    protected void GridUsers_RowCreated(object sender, GridViewRowEventArgs e)
    { 

 

    }
}

Open in new window

Avatar of nmarun
nmarun
Flag of India image

ASKER CERTIFIED SOLUTION
Avatar of Fab_C
Fab_C
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial