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");
}
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");
}