W
WebBuilder451
I'm adding subheadings to a gridview. Each sub head has a few link buttons.
I'm adding the controls in the rowdatabound event code follows: sorry about
the length here. I have to be missing something. The buttons show up and post
back, but the events do not fire.
any help would be appreciated!!!
Thank you.
protected void gvEntitiesRowDataBound(object sender, GridViewRowEventArgs
e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
EntityReport er = (EntityReport)e.Row.DataItem;
if (er.SzName != ctrlName)
{
GridViewRow gvr = new GridViewRow(0, 0,
DataControlRowType.Header, DataControlRowState.Insert);
TableCell td = new TableCell();
td.ColumnSpan = 9;
td.Font.Bold = true;
td.Font.Size = FontUnit.Smaller;
td.HorizontalAlign = HorizontalAlign.Center;
td.BackColor = System.Drawing.Color.Bisque;
LinkButton lbtn = new LinkButton();
lbtn.ID = "EditEntity";
lbtn.CommandArgument = er.IEntityID.ToString();
lbtn.CommandName = "Edit Entity";
lbtn.Command += EditEntityCommand;
lbtn.Text = "(edit)";
td.Controls.Add(lbtn);
Literal ltr = new Literal();
ltr.Text = " ";
td.Controls.Add(ltr);
Label lbl = new Label();
lbl.Text = er.SzName + " (" + er.EntityTypeDesc + ", " + ""
+ ") - ";
td.Controls.Add(lbl);
Literal ltr1 = new Literal();
ltr1.Text = " ";
td.Controls.Add(ltr1);
LinkButton lbtn2 = new LinkButton();
lbtn2.ID = "NewEntity";
lbtn2.CommandArgument = er.IEntityID.ToString();
lbtn2.CommandName = "newEntity";
lbtn2.Command += EditEntityCommand;
lbtn2.Text = "Add new person or Institution";
td.Controls.Add(lbtn2);
Literal ltr2 = new Literal();
ltr2.Text = "<br />";
td.Controls.Add(ltr2);
LinkButton lbtn3 = new LinkButton();
lbtn3.ID = "NewEmail";
lbtn3.CommandArgument = er.IEntityID.ToString();
lbtn3.CommandName = "newEntity";
lbtn3.Command += EditEntityCommand;
lbtn3.Text = "Add new email for contact";
td.Controls.Add(lbtn3);
Literal ltr3 = new Literal();
ltr3.Text = " ";
td.Controls.Add(ltr3);
LinkButton lbtn4 = new LinkButton();
lbtn4.ID = "NewPhone";
lbtn4.CommandArgument = er.IEntityID.ToString();
lbtn4.CommandName = "newEntity";
lbtn4.Command += EditEntityCommand;
lbtn4.Text = "Add new phone for contact";
td.Controls.Add(lbtn4);
Literal ltr4 = new Literal();
ltr4.Text = " ";
td.Controls.Add(ltr4);
gvr.Cells.Add(td);
gvEntities.Controls[0].Controls.AddAt(e.Row.DataItemIndex +
icur, gvr);
ctrlName = er.SzName;
icur+=1;
}
}
}
// this is the function that is to be fired
protected void EditEntityCommand(object sender, CommandEventArgs e)
{
....
....
}
i set a break point here and this does not get hit.
--
(i''ll be asking a lot of these, but I find C# totally way cooler than vb
and there''s no go''n back!!!)
thanks (as always)
kes
I'm adding the controls in the rowdatabound event code follows: sorry about
the length here. I have to be missing something. The buttons show up and post
back, but the events do not fire.
any help would be appreciated!!!
Thank you.
protected void gvEntitiesRowDataBound(object sender, GridViewRowEventArgs
e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
EntityReport er = (EntityReport)e.Row.DataItem;
if (er.SzName != ctrlName)
{
GridViewRow gvr = new GridViewRow(0, 0,
DataControlRowType.Header, DataControlRowState.Insert);
TableCell td = new TableCell();
td.ColumnSpan = 9;
td.Font.Bold = true;
td.Font.Size = FontUnit.Smaller;
td.HorizontalAlign = HorizontalAlign.Center;
td.BackColor = System.Drawing.Color.Bisque;
LinkButton lbtn = new LinkButton();
lbtn.ID = "EditEntity";
lbtn.CommandArgument = er.IEntityID.ToString();
lbtn.CommandName = "Edit Entity";
lbtn.Command += EditEntityCommand;
lbtn.Text = "(edit)";
td.Controls.Add(lbtn);
Literal ltr = new Literal();
ltr.Text = " ";
td.Controls.Add(ltr);
Label lbl = new Label();
lbl.Text = er.SzName + " (" + er.EntityTypeDesc + ", " + ""
+ ") - ";
td.Controls.Add(lbl);
Literal ltr1 = new Literal();
ltr1.Text = " ";
td.Controls.Add(ltr1);
LinkButton lbtn2 = new LinkButton();
lbtn2.ID = "NewEntity";
lbtn2.CommandArgument = er.IEntityID.ToString();
lbtn2.CommandName = "newEntity";
lbtn2.Command += EditEntityCommand;
lbtn2.Text = "Add new person or Institution";
td.Controls.Add(lbtn2);
Literal ltr2 = new Literal();
ltr2.Text = "<br />";
td.Controls.Add(ltr2);
LinkButton lbtn3 = new LinkButton();
lbtn3.ID = "NewEmail";
lbtn3.CommandArgument = er.IEntityID.ToString();
lbtn3.CommandName = "newEntity";
lbtn3.Command += EditEntityCommand;
lbtn3.Text = "Add new email for contact";
td.Controls.Add(lbtn3);
Literal ltr3 = new Literal();
ltr3.Text = " ";
td.Controls.Add(ltr3);
LinkButton lbtn4 = new LinkButton();
lbtn4.ID = "NewPhone";
lbtn4.CommandArgument = er.IEntityID.ToString();
lbtn4.CommandName = "newEntity";
lbtn4.Command += EditEntityCommand;
lbtn4.Text = "Add new phone for contact";
td.Controls.Add(lbtn4);
Literal ltr4 = new Literal();
ltr4.Text = " ";
td.Controls.Add(ltr4);
gvr.Cells.Add(td);
gvEntities.Controls[0].Controls.AddAt(e.Row.DataItemIndex +
icur, gvr);
ctrlName = er.SzName;
icur+=1;
}
}
}
// this is the function that is to be fired
protected void EditEntityCommand(object sender, CommandEventArgs e)
{
....
....
}
i set a break point here and this does not get hit.
--
(i''ll be asking a lot of these, but I find C# totally way cooler than vb
and there''s no go''n back!!!)
thanks (as always)
kes