Re: GridView
On Jun 1, 3:26 pm, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
Back to the original question and the solution you've just provided.
I've noticed that when I press the save button, that's being placed
somewhere
outside the gridview control (which causes the postback and hence the
submit behavior),
the row# column doesn't get updated. I've traced the code and I
noticed that the
gridView_RowDat aBound function doesn't get called for DataRow row
types!!!
Would you please let me know what's going on wrong and how am I
supposed to fix this?
Thanks
On Jun 1, 3:26 pm, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
<a...@mailinato r.comwrote in message
>
news:38694e80-884e-4a8b-83d0-a4c17c4afa25@m3 g2000hsc.google groups.com...
>
>
Firstly, you're not "supposed to" have a RowIndex column - there's no law
that says you have to have one...
>
However, it's easy enough:
>
1) Add a template field to your existing GridView:
>
<asp:TemplateFi eld HeaderText="Row Index">
<ItemTemplate >
<asp:Label ID="lblRowIndws " runat="server" />
</ItemTemplate>
</asp:TemplateFie ld>
>
2) Wire up a RowDataBound event to your GridView if it doesn't already have
one:http://msdn.microsoft.com/en-us/libr...ebcontrols.gri...
>
3) Add the following code to the RowDataBound event:
>
protected void gvResults_RowDa taBound(object sender, GridViewRowEven tArgs e)
{
if (e.Row.RowType == DataControlRowT ype.DataRow)
{
e.Row.Cells[0].Text = e.Row.RowIndex. ToString();
//e.Row.Cells[6].Text = (Convert.ToInt3 2(e.Row.RowInde x) +
1).ToString();
}
>
}
>
Remember to modify the cell indexer accordingly...
>
>
Can you please explain what you mean by "given TAG object"...?
>
--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
>
news:38694e80-884e-4a8b-83d0-a4c17c4afa25@m3 g2000hsc.google groups.com...
>
1. How am I supposed to have a RowIndex column *without* modifying the
Entity class?
Entity class?
Firstly, you're not "supposed to" have a RowIndex column - there's no law
that says you have to have one...
>
However, it's easy enough:
>
1) Add a template field to your existing GridView:
>
<asp:TemplateFi eld HeaderText="Row Index">
<ItemTemplate >
<asp:Label ID="lblRowIndws " runat="server" />
</ItemTemplate>
</asp:TemplateFie ld>
>
2) Wire up a RowDataBound event to your GridView if it doesn't already have
one:http://msdn.microsoft.com/en-us/libr...ebcontrols.gri...
>
3) Add the following code to the RowDataBound event:
>
protected void gvResults_RowDa taBound(object sender, GridViewRowEven tArgs e)
{
if (e.Row.RowType == DataControlRowT ype.DataRow)
{
e.Row.Cells[0].Text = e.Row.RowIndex. ToString();
//e.Row.Cells[6].Text = (Convert.ToInt3 2(e.Row.RowInde x) +
1).ToString();
}
>
}
>
Remember to modify the cell indexer accordingly...
>
2. How am I supposed to assign a given TAG object to each row?
Can you please explain what you mean by "given TAG object"...?
>
--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
I've noticed that when I press the save button, that's being placed
somewhere
outside the gridview control (which causes the postback and hence the
submit behavior),
the row# column doesn't get updated. I've traced the code and I
noticed that the
gridView_RowDat aBound function doesn't get called for DataRow row
types!!!
Would you please let me know what's going on wrong and how am I
supposed to fix this?
Thanks
Comment