A
Alejandro Penate-Diaz
Hi. I am trying to reduce a DataGrid viewstate info by doing what this article says: http://authors.aspalliance.com/JimRoss/Articles/DatagridDietPartTwo.aspx .. I need to disable viewstate for all columns exept my button columns. Problem is that I can not access the Label controls within datagrid cells. I tried:
TableCell Cell3 = e.Item.Cells[3];
((Label)Cell3.Controls[1]).Text;
but then I get empty strings. Also inside a cell I found a LiteralControl and a Label in position 0 and 1 respectively but both are empty.
Here is a fragment of my datagrid and I need to retrieve programmaticaly the value for th Label in red.
<asp:datagrid id="DataGrid1" runat="server" Width="1000px" BackColor="AliceBlue" AllowSorting="True"
AutoGenerateColumns="False" Font-Size="Smaller">
<AlternatingItemStyle BackColor="GhostWhite"></AlternatingItemStyle>
<HeaderStyle Font-Size="Smaller" Font-Names="Arial" Font-Bold="True" Wrap="False" HorizontalAlign="Center"
BorderStyle="Groove" VerticalAlign="Middle" BackColor="GhostWhite"></HeaderStyle>
<Columns>
<asp:EditCommandColumn Visible="False" ButtonType="PushButton" UpdateText="Update" CancelText="Cancel"
EditText="Edit"></asp:EditCommandColumn>
<asp:ButtonColumn Text="View" ButtonType="PushButton" CommandName="Delete">
<HeaderStyle Width="50px"></HeaderStyle>
</asp:ButtonColumn>
<asp:TemplateColumn>
<HeaderStyle Width="200px"></HeaderStyle>
<ItemTemplate>
<asp:Label runat="server"
EnableViewState="False"
Text='<%# DataBinder.Eval(Container, "DataItem.Serial") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Serial") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
Thanks,
Alejandro
TableCell Cell3 = e.Item.Cells[3];
((Label)Cell3.Controls[1]).Text;
but then I get empty strings. Also inside a cell I found a LiteralControl and a Label in position 0 and 1 respectively but both are empty.
Here is a fragment of my datagrid and I need to retrieve programmaticaly the value for th Label in red.
<asp:datagrid id="DataGrid1" runat="server" Width="1000px" BackColor="AliceBlue" AllowSorting="True"
AutoGenerateColumns="False" Font-Size="Smaller">
<AlternatingItemStyle BackColor="GhostWhite"></AlternatingItemStyle>
<HeaderStyle Font-Size="Smaller" Font-Names="Arial" Font-Bold="True" Wrap="False" HorizontalAlign="Center"
BorderStyle="Groove" VerticalAlign="Middle" BackColor="GhostWhite"></HeaderStyle>
<Columns>
<asp:EditCommandColumn Visible="False" ButtonType="PushButton" UpdateText="Update" CancelText="Cancel"
EditText="Edit"></asp:EditCommandColumn>
<asp:ButtonColumn Text="View" ButtonType="PushButton" CommandName="Delete">
<HeaderStyle Width="50px"></HeaderStyle>
</asp:ButtonColumn>
<asp:TemplateColumn>
<HeaderStyle Width="200px"></HeaderStyle>
<ItemTemplate>
<asp:Label runat="server"
EnableViewState="False"
Text='<%# DataBinder.Eval(Container, "DataItem.Serial") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Serial") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
Thanks,
Alejandro