Ver Mensaje Individual
  #5 (permalink)  
Antiguo 26/04/2010, 10:00
soulforged
 
Fecha de Ingreso: marzo-2010
Mensajes: 8
Antigüedad: 14 años, 1 mes
Puntos: 0
Respuesta: Ancho columnas Gridview

Ok, ahora pongo el código. Creo que todos mis problemas se deben a que doy unos valores de anchura y de visible antes de que los datos se "bindeen", por tanto, cuando se "bindean" al estar la columna a visible=false no se bindea esa columna, y la anchura del resto se amolda a los datos bindeados.

PD. Utilizo un AccesDataSource para meter los datos en la tabla.

Código ASP:
Ver original
  1. <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
  2.                     AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="usuario,hora"
  3.                     DataSourceID="AccessDataSource1" EnableSortingAndPagingCallbacks="True"
  4.                     Width="299px">
  5.                     <PagerSettings FirstPageText="Principio" LastPageText="Final"
  6.                         NextPageText="Siguiente" PreviousPageText="Anterior" />
  7.                     <RowStyle Wrap="True" />
  8.                     <Columns>
  9.                         <asp:TemplateField>
  10.                             <ItemTemplate>
  11.                                 <asp:CheckBox ID="Selector" runat="server" />
  12.                             </ItemTemplate>
  13.                         </asp:TemplateField>
  14.                         <asp:BoundField DataField="usuario" HeaderText="usuario" ReadOnly="True"
  15.                             SortExpression="usuario">
  16.                             <FooterStyle HorizontalAlign="Center" Width="20px" Wrap="False" />
  17.                             <HeaderStyle HorizontalAlign="Center" Width="20px" Wrap="False" />
  18.                             <ItemStyle HorizontalAlign="Center" Width="20px" Wrap="False" />
  19.                         </asp:BoundField>
  20.                         <asp:BoundField DataField="hora" HeaderText="hora" ReadOnly="True"
  21.                             SortExpression="hora">
  22.                             <FooterStyle HorizontalAlign="Center" Width="20px" Wrap="False" />
  23.                             <HeaderStyle HorizontalAlign="Center" Width="20px" Wrap="False" />
  24.                             <ItemStyle HorizontalAlign="Center" Width="100px" Wrap="False" />
  25.                         </asp:BoundField>
  26.                         <asp:BoundField DataField="tipo" HeaderText="tipo" SortExpression="tipo">
  27.                             <ControlStyle Width="20px" />
  28.                             <FooterStyle Width="20px" Wrap="False" />
  29.                             <HeaderStyle Width="20px" Wrap="False" />
  30.                             <ItemStyle Width="100px" Wrap="False" />
  31.                         </asp:BoundField>
  32.                         <asp:BoundField ItemStyle-Width="1" DataField="dato" HeaderText="dato"
  33.                             SortExpression="dato" ReadOnly="true">
  34.                            
  35.                            
  36.                             <ItemStyle Width="100px" HorizontalAlign="Left" Wrap="False" />
  37.                            
  38.                            
  39.                         </asp:BoundField>
  40.                     </Columns>
  41.                     <PagerStyle HorizontalAlign="Center" />
  42.                     <SelectedRowStyle BackColor="#CCFFFF" BorderStyle="Solid" Font-Bold="True" />
  43.                     <EditRowStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="20px"
  44.                         Wrap="True" />
  45.                     <AlternatingRowStyle BackColor="#CCFFCC" HorizontalAlign="Center"
  46.                         VerticalAlign="Middle" />
  47.                 </asp:GridView>

Código C#:
Ver original
  1. protected void BotonDibujar_Click(object sender, EventArgs e)
  2.     {
  3.  
  4.         foreach (GridViewRow row in GridView1.Rows)
  5.         {
  6.             CheckBox cb = (CheckBox)row.FindControl("Selector");
  7.             if (cb != null && cb.Checked)
  8.             {
  9.                
  10.                 s = s + row.Cells[4].Text + ";";
  11. ...