N
nipe
Hello,
I'm having problem with my custom datagrid control can't fire
itemcommand event.
The fact is that I have to make fully cutom user control so I can't do
any scripting to .aspx file.
There are two classes that has something to do with this: datagrid
class which has 2 buttoncolumns and panel class that HAS datagrid and
handles itemcommand event.
//datagrid class is like this
public class MyDataGrid : DataGrid , INamingContainer
{
....
ButtonColumn brisiButCol = new ButtonColumn();
ButtonColumn saljiButCol = new ButtonColumn();
protected override void OnInit(EventArgs e)
{
Inicijalizuj();
base.OnInit(e);
}
private void Inicijalizuj()
{
this.AutoGenerateColumns = false;
....
brisiButCol.Text = "Brisi";
brisiButCol.CommandName = "Delete";
brisiButCol.ButtonType = ButtonColumnType.PushButton;
saljiButCol.Text = "Salji";
saljiButCol.CommandName = "Salji";
saljiButCol.ButtonType = ButtonColumnType.PushButton;
}
public void DodajKolone()
{
this.Columns.Add(col1);
this.Columns.Add(col2);
this.Columns.Add(col3);
this.Columns.Add(brisiButCol);
this.Columns.Add(saljiButCol);
}
}
//and the panel class is like this:
class FajloviPanel : Panel, INamingContainer
{
internal MyDataGrid fajloviDataGrid = new MyDataGrid();
.....
protected override void OnInit(EventArgs e)
{
InicijalizujKontrole();
base.OnInit(e);
}
private void InicijalizujKontrole()
{
fajloviDataGrid.ItemCommand += new
DataGridCommandEventHandler(fajloviDataGrid_ItemCommand);
....
}
protected override void CreateChildControls()
{
fajloviDataGrid.DodajKolone();
Controls.Add(fajloviDataGrid);
....
fajloviDataGrid.DataBind();
base.CreateChildControls();
}
}
Like I said, application naver gets into fajloviDataGrid_ItemCommand
method.
I'm sorry I don't have much experience in ASP.NET so maybe there is
some lame mistake, but I'm having troubles with this for a pretty long
time..
Any suggestion will help.
Thanks!
Nikola
I'm having problem with my custom datagrid control can't fire
itemcommand event.
The fact is that I have to make fully cutom user control so I can't do
any scripting to .aspx file.
There are two classes that has something to do with this: datagrid
class which has 2 buttoncolumns and panel class that HAS datagrid and
handles itemcommand event.
//datagrid class is like this
public class MyDataGrid : DataGrid , INamingContainer
{
....
ButtonColumn brisiButCol = new ButtonColumn();
ButtonColumn saljiButCol = new ButtonColumn();
protected override void OnInit(EventArgs e)
{
Inicijalizuj();
base.OnInit(e);
}
private void Inicijalizuj()
{
this.AutoGenerateColumns = false;
....
brisiButCol.Text = "Brisi";
brisiButCol.CommandName = "Delete";
brisiButCol.ButtonType = ButtonColumnType.PushButton;
saljiButCol.Text = "Salji";
saljiButCol.CommandName = "Salji";
saljiButCol.ButtonType = ButtonColumnType.PushButton;
}
public void DodajKolone()
{
this.Columns.Add(col1);
this.Columns.Add(col2);
this.Columns.Add(col3);
this.Columns.Add(brisiButCol);
this.Columns.Add(saljiButCol);
}
}
//and the panel class is like this:
class FajloviPanel : Panel, INamingContainer
{
internal MyDataGrid fajloviDataGrid = new MyDataGrid();
.....
protected override void OnInit(EventArgs e)
{
InicijalizujKontrole();
base.OnInit(e);
}
private void InicijalizujKontrole()
{
fajloviDataGrid.ItemCommand += new
DataGridCommandEventHandler(fajloviDataGrid_ItemCommand);
....
}
protected override void CreateChildControls()
{
fajloviDataGrid.DodajKolone();
Controls.Add(fajloviDataGrid);
....
fajloviDataGrid.DataBind();
base.CreateChildControls();
}
}
Like I said, application naver gets into fajloviDataGrid_ItemCommand
method.
I'm sorry I don't have much experience in ASP.NET so maybe there is
some lame mistake, but I'm having troubles with this for a pretty long
time..
Any suggestion will help.
Thanks!
Nikola