Hello Dear Professionals:
Based on this document:
http://msdn.microsoft.com/library/de...ynamically.asp
or this http://www.dnzone.com/ShowDetail.asp?NewsId=599
I want to create 3 template column in datagrid dynamically while the
template columns
contains image buttons for add, edit and delete. As you can see, I can
figure out the commandname inside the imageButton_Com mand event but I do not
know how can store info in session object and also use response.redire ct
inside that event cause it is in the DataGridTemplat e Class not the upper
user control which contains that class. Also access other datagrid columns'
data like id of current datagrid row.
Thank you very much for your kind attention.
Best Wishes
Andy Eshtry
an********@hotm ail.com
public class DataGridTemplat e : System.Web.UI.I Template
{
ListItemType templateType;
string columnName;
public DataGridTemplat e(ListItemType type, string colname)
{
templateType = type;
columnName = colname;
}
public void InstantiateIn(S ystem.Web.UI.Co ntrol container)
{
Literal lc = new Literal();
switch(template Type)
{
case ListItemType.He ader:
lc.Text = "<B>" + columnName + "</B>";
container.Contr ols.Add(lc);
break;
case ListItemType.It em:
ImageButton imageButton = new ImageButton();
imageButton.Ima geUrl = "../Images/view.png";
imageButton.Alt ernateText = columnName;
imageButton.Com mand += new CommandEventHan dler(imageButto n_Command);
imageButton.Com mandName = "View";
container.Contr ols.Add(imageBu tton);
break;
}
}
void imageButton_Com mand(object sender, CommandEventArg s e)
{
if (e.CommandName == "View")
{
//can not use session or response.redire ct or how can I sent commandname up
to container user control or access other datagrid columns's data
}
}