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!!!
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)
{
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://stackoverflow.com/questions/394989/gridview-link-button-click-event-windows-application
http://forums.asp.net/t/1222886.aspx
http://stackoverflow.com/questions/2186191/why-wont-my-linkbutton-inside-a-gridview-raise-its-onclick-event
Arun