[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webcontrols

Dynamic temp. datagrid col.gen. -Session access inside a class inside a UserCtrl

Andy Eshtry

3/1/2004 11:47:00 PM

Hello Dear Professionals:
Based on this document:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskcreatingwebservercontroltemplatesdynam...
or this http://www.dnzone.com/ShowDetail.asp?...
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_Command event but I do not
know how can store info in session object and also use response.redirect
inside that event cause it is in the DataGridTemplate 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
andyeshtry@hotmail.com


public class DataGridTemplate : System.Web.UI.ITemplate
{
ListItemType templateType;
string columnName;

public DataGridTemplate(ListItemType type, string colname)
{
templateType = type;
columnName = colname;
}

public void InstantiateIn(System.Web.UI.Control container)
{
Literal lc = new Literal();
switch(templateType)
{
case ListItemType.Header:
lc.Text = "<B>" + columnName + "</B>";
container.Controls.Add(lc);
break;
case ListItemType.Item:
ImageButton imageButton = new ImageButton();
imageButton.ImageUrl = "../Images/view.png";
imageButton.AlternateText = columnName;
imageButton.Command += new CommandEventHandler(imageButton_Command);
imageButton.CommandName = "View";
container.Controls.Add(imageButton);
break;
}
}

void imageButton_Command(object sender, CommandEventArgs e)
{
if (e.CommandName == "View")
{
//can not use session or response.redirect or how can I sent commandname up
to container user control or access other datagrid columns's data
}
}