Dynamic Template firing DataGridCommandEventHandler

M

MattB

Hello I am adding Columns to my datagrid in the page load event but
cannot get an event to load or read any eventargs on post back, here
is my control....



using System;
using System.Web;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MyTemplateColumn
{
/// <summary>
/// Summary description for GenericItem.
/// </summary>
public class ColumnLinkCommandItem : ITemplate
{
private string column;
private string argcolumn;

public ColumnLinkCommandItem(string column,string argcolumn)
{
this.column = column;
this.argcolumn = argcolumn;
}
public void InstantiateIn(Control container)
{
LinkButton lb = new LinkButton();
lb.CommandName = "Select";
lb.DataBinding += new EventHandler(this.BindData);
container.Controls.Add(lb);
}

public void BindData(object sender, EventArgs e)
{
LinkButton lb = (LinkButton) sender;
DataGridItem container = (DataGridItem) lb.NamingContainer;
lb.ID="DocItem";
lb.Text = ((DataRowView) container.DataItem)[column].ToString();
lb.CommandArgument = ((DataRowView)
container.DataItem)[column].ToString() + ":" + ((DataRowView)
container.DataItem)[argcolumn].ToString();
lb.CommandName = "Select";
lb.Attributes.Add("Runat","server");
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,737
Latest member
Georgeengab

Latest Threads

Top