Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Andy Eshtry #1
Dynamic temp. datagrid col.gen. -Session access inside a class inside a UserCtrl
Hello Dear Professionals:
Based on this document:
[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskcreatingwebservercontroltemplatesdynamically. asp[/url]
or this [url]http://www.dnzone.com/ShowDetail.asp?NewsId=599[/url]
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
[email]andyeshtry@hotmail.com[/email]
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
}
}
Andy Eshtry Guest
-
How can I access a component inside a class file?
If I set up a component in Main.mxml e.g. <mx:Text id="stxt" text="" width="240" height="650"/> How can I set the text in an imported class... -
can i use dynamic variable inside a dataadapter and bind to datagrid
Hi I want to use a sql designed in the dataadapter and I want to pass a variable so it can retrieve related data by using "WHERE" clause in the... -
How to access the controls that are inside of a DataList/DataGrid using JS?
My problem is simple, i have a datalist control with some controls inside of EditTemplate (the problem is the same in the DataGrid). I want to have... -
Using class inside ASP
Hi all professional I would like to know how to using java class file inside ASP page I have placed the class file to C:\WINNT\java\trustlib... -
#23038 [Com]: PHP does not detect parent class inside child class' constructor
ID: 23038 Comment by: hewei at ied dot org dot cn Reported By: black at sunshine dot krneki dot org Status: ... -
Andy Eshtry #2
Dynamic temp. datagrid col.gen. -Session access inside a class inside a UserCtrl
Hello Dear Professionals:
Based on this document:
[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskcreatingwebservercontroltemplatesdynamically. asp[/url]
or this [url]http://www.dnzone.com/ShowDetail.asp?NewsId=599[/url]
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
[email]andyeshtry@hotmail.com[/email]
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
}
}
Andy Eshtry Guest



Reply With Quote

