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 7 6041
You don't need to add controls dynamically. Instead, use templated fields
made out of 2 rows, one for regular items and another for those with
subheadings. In the RowDataBound event decide if you need to show
subheadings.
If you can, it is better to use a ListView control since it allows using one
item template for the whole row, like in a repeater, as opposed to per-field
templates in GridView.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"WebBuilder451" <We***********@discussions.microsoft.comwrote in message
news:D5**********************************@microsof t.com...
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
thanks, I'll need to learn how and doing that now.
appreciated
--
(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
"Eliyahu Goldin" wrote:
You don't need to add controls dynamically. Instead, use templated fields
made out of 2 rows, one for regular items and another for those with
subheadings. In the RowDataBound event decide if you need to show
subheadings.
If you can, it is better to use a ListView control since it allows using one
item template for the whole row, like in a repeater, as opposed to per-field
templates in GridView.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"WebBuilder451" <We***********@discussions.microsoft.comwrote in message
news:D5**********************************@microsof t.com...
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
amended..
can you share an example or point to an aritcal that covers what you suggest?
--
(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
"Eliyahu Goldin" wrote:
You don't need to add controls dynamically. Instead, use templated fields
made out of 2 rows, one for regular items and another for those with
subheadings. In the RowDataBound event decide if you need to show
subheadings.
If you can, it is better to use a ListView control since it allows using one
item template for the whole row, like in a repeater, as opposed to per-field
templates in GridView.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"WebBuilder451" <We***********@discussions.microsoft.comwrote in message
news:D5**********************************@microsof t.com...
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
Here is an example for a repeater. It will help you to get the idea:
<asp:repeater>
<headertemplate>
<table>
</headertemplate>
<itemtemplate>
<tr runat="server" id="trNormal">
<td>Databind expression for column 1</td>
<td>Databind expression for column 2</td>
<td>Databind expression for column 3</td>
</tr>
<tr runat="server" id="trSubheadings">
<td>Databind expression for subheading 1</td>
<td>Databind expression for subheading 2</td>
<td>Databind expression for subheading 3</td>
</tr>
</itemtemplate>
</asp:repeater>
<footertemplate>
</table>
</footertemplate>
Handle ItemDataBound event to hide trNormal or trSubheadings as needed.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"WebBuilder451" <We***********@discussions.microsoft.comwrote in message
news:B5**********************************@microsof t.com...
amended..
can you share an example or point to an aritcal that covers what you
suggest?
--
(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
"Eliyahu Goldin" wrote:
>You don't need to add controls dynamically. Instead, use templated fields made out of 2 rows, one for regular items and another for those with subheadings. In the RowDataBound event decide if you need to show subheadings.
If you can, it is better to use a ListView control since it allows using one item template for the whole row, like in a repeater, as opposed to per-field templates in GridView.
-- Eliyahu Goldin, Software Developer Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"WebBuilder451" <We***********@discussions.microsoft.comwrote in message news:D5**********************************@microso ft.com...
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
ok, thanks
This was a bit more straight forward than i expected. I thought you ment to
create a custom template type for the subhead. perhaps using template builder.
thanks very much appreciated.
--
(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
"Eliyahu Goldin" wrote:
Here is an example for a repeater. It will help you to get the idea:
<asp:repeater>
<headertemplate>
<table>
</headertemplate>
<itemtemplate>
<tr runat="server" id="trNormal">
<td>Databind expression for column 1</td>
<td>Databind expression for column 2</td>
<td>Databind expression for column 3</td>
</tr>
<tr runat="server" id="trSubheadings">
<td>Databind expression for subheading 1</td>
<td>Databind expression for subheading 2</td>
<td>Databind expression for subheading 3</td>
</tr>
</itemtemplate>
</asp:repeater>
<footertemplate>
</table>
</footertemplate>
Handle ItemDataBound event to hide trNormal or trSubheadings as needed.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"WebBuilder451" <We***********@discussions.microsoft.comwrote in message
news:B5**********************************@microsof t.com...
amended..
can you share an example or point to an aritcal that covers what you
suggest?
--
(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
"Eliyahu Goldin" wrote:
You don't need to add controls dynamically. Instead, use templated fields
made out of 2 rows, one for regular items and another for those with
subheadings. In the RowDataBound event decide if you need to show
subheadings.
If you can, it is better to use a ListView control since it allows using
one
item template for the whole row, like in a repeater, as opposed to
per-field
templates in GridView.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"WebBuilder451" <We***********@discussions.microsoft.comwrote in
message
news:D5**********************************@microsof t.com...
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
Hi ,
As i am new in asp.net c# ,can you please make it more specififc.
I am using a repeater control and i bound the columns like this
td><%#DataBinder.Eval(Container.DataItem, "q2option")%></td>
<td><%#DataBinder.Eval(Container.DataItem, "q3option")%></td>
<td><%#DataBinder.Eval(Container.DataItem, "q4option")%></td>
<td><%#DataBinder.Eval(Container.DataItem, "q5option")%></td>
<td><%#DataBinder.Eval(Container.DataItem, "q6option")%></td>
<td><%#DataBinder.Eval(Container.DataItem, "q7option")%></td>
<td><%#DataBinder.Eval(Container.DataItem, "q8option")%></td>
<td><%#DataBinder.Eval(Container.DataItem, "q9option")%></td>
</tr>
I mean in the databind expression for subheading how can i do that.
This is veru urgent.Please help me.
I am running out of time.
Thanks in advance.
"Eliyahu Goldin" wrote:
Here is an example for a repeater. It will help you to get the idea:
<asp:repeater>
<headertemplate>
<table>
</headertemplate>
<itemtemplate>
<tr runat="server" id="trNormal">
<td>Databind expression for column 1</td>
<td>Databind expression for column 2</td>
<td>Databind expression for column 3</td>
</tr>
<tr runat="server" id="trSubheadings">
<td>Databind expression for subheading 1</td>
<td>Databind expression for subheading 2</td>
<td>Databind expression for subheading 3</td>
</tr>
</itemtemplate>
</asp:repeater>
<footertemplate>
</table>
</footertemplate>
Handle ItemDataBound event to hide trNormal or trSubheadings as needed.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"WebBuilder451" <We***********@discussions.microsoft.comwrote in message
news:B5**********************************@microsof t.com...
amended..
can you share an example or point to an aritcal that covers what you
suggest?
--
(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
"Eliyahu Goldin" wrote:
You don't need to add controls dynamically. Instead, use templated fields
made out of 2 rows, one for regular items and another for those with
subheadings. In the RowDataBound event decide if you need to show
subheadings.
If you can, it is better to use a ListView control since it allows using
one
item template for the whole row, like in a repeater, as opposed to
per-field
templates in GridView.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"WebBuilder451" <We***********@discussions.microsoft.comwrote in
message
news:D5**********************************@microsof t.com...
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
And one more thing ,
Based on the search result i have to show the header for each category of
products.
Please help
"WebBuilder451" wrote:
ok, thanks
This was a bit more straight forward than i expected. I thought you ment to
create a custom template type for the subhead. perhaps using template builder.
thanks very much appreciated.
--
(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
"Eliyahu Goldin" wrote:
Here is an example for a repeater. It will help you to get the idea:
<asp:repeater>
<headertemplate>
<table>
</headertemplate>
<itemtemplate>
<tr runat="server" id="trNormal">
<td>Databind expression for column 1</td>
<td>Databind expression for column 2</td>
<td>Databind expression for column 3</td>
</tr>
<tr runat="server" id="trSubheadings">
<td>Databind expression for subheading 1</td>
<td>Databind expression for subheading 2</td>
<td>Databind expression for subheading 3</td>
</tr>
</itemtemplate>
</asp:repeater>
<footertemplate>
</table>
</footertemplate>
Handle ItemDataBound event to hide trNormal or trSubheadings as needed.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"WebBuilder451" <We***********@discussions.microsoft.comwrote in message
news:B5**********************************@microsof t.com...
amended..
can you share an example or point to an aritcal that covers what you
suggest?
--
(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
>
>
"Eliyahu Goldin" wrote:
>
>You don't need to add controls dynamically. Instead, use templated fields
>made out of 2 rows, one for regular items and another for those with
>subheadings. In the RowDataBound event decide if you need to show
>subheadings.
>>
>If you can, it is better to use a ListView control since it allows using
>one
>item template for the whole row, like in a repeater, as opposed to
>per-field
>templates in GridView.
>>
>--
>Eliyahu Goldin,
>Software Developer
>Microsoft MVP [ASP.NET]
>http://msmvps.com/blogs/egoldin
>http://usableasp.net
>>
>>
>"WebBuilder451" <We***********@discussions.microsoft.comwrote in
>message
>news:D5**********************************@microso ft.com...
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
>>
>>
>>
This discussion thread is closed Replies have been disabled for this discussion. Similar topics
3 posts
views
Thread by Jim Heavey |
last post: by
|
reply
views
Thread by Sileesh |
last post: by
|
reply
views
Thread by Luis Esteban Valencia |
last post: by
|
reply
views
Thread by ami |
last post: by
| |
2 posts
views
Thread by Kbalz |
last post: by
|
2 posts
views
Thread by gnewsgroup |
last post: by
|
1 post
views
Thread by Paddy |
last post: by
|
reply
views
Thread by Andy B |
last post: by
| | | | | | | | | | |