title: fixing width of a gridview in asp.net
body: <p>I want to fix width of gridview. I am filling gridview as following;</p>
  
  <pre><code>sorgu = "select urun.urunId as \"İş No\",urun.modelNo as \"Model No\",modelAd as \"Model Adı\",bedenAd as \"Beden\", adet as \"Adet\""
                + ",aciklama as \"Açıklama\", kesmeTalimat as \"Kesim Talimatı\", atolyeTalimat as \"Atölye Talimatı\", yikamaTalimat as \"Yıkama Talimatı\", utuTalimat as \"Ütü Talimatı\", (k4.ad+' '+k4.soyad) as \"Kesim\", (k1.ad+' '+k1.soyad) as \"Atölye\""
                + ",(k2.ad+' '+k2.soyad) as \"Yıkama\",(k3.ad+' '+k3.soyad) as \"Ütü\", (k5.ad+' '+k5.soyad) as \"Kontrol\" from kullanici k1,kullanici k4,kullanici k5,kullanici k2,kullanici k3,model,beden,urun,fason,isTalimat,durum"
                + " where urun.urunId= fason.urunId and urun.urunId=isTalimat.urunId and urun.urunId=durum.urunId and model.modelNo=urun.modelNo and beden.bedenNo=urun.bedenNo and"
                + " fason.atolye=k1.id and fason.yikama=k2.id and fason.kesimci=k4.id and fason.kontrol=k5.id and fason.utu=k3.id";
          connection.Open();
          command.Connection = connection;
          command.CommandText = sorgu;
          dr = command.ExecuteReader();
          DataTable dtTumISler = new DataTable();
          dtTumISler.Load(dr);
          dgvTumIsler.DataSource = dtTumISler;
          dgvTumIsler.DataBind();
          dr.Close();
          connection.Close();
          dtTumISler.Dispose();
  </code></pre>
  
  <p>Here dgvTumİsler is my gridview. I have tried the following code to make fixed length. But it does not work;</p>
  
  <pre><code>for (int i = 0; i &lt; dgvTumIsler.Columns.Count; i++)
          {
              dgvTumIsler.Columns[i].ItemStyle.Width = 100;
          }
  </code></pre>
  
  <p>Here dgvTumİsler.Columns.Count  value is 1. So it does not work. Is there a way to solve this problem or is there another way to make a gridview fixed width.</p>
  
  <p>HTML code:</p>
  
  <pre><code>&lt;asp:GridView ID="dgvTumIsler" runat="server" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" OnSelectedIndexChanged="dgvTumIsler_SelectedIndexChanged"&gt;
                           &lt;Columns&gt;
                               &lt;asp:CommandField ButtonType="Button" SelectText="Seç" ShowCancelButton="False" ShowSelectButton="True" /&gt;
                           &lt;/Columns&gt;
                           &lt;FooterStyle BackColor="White" ForeColor="#000066" /&gt;
                           &lt;HeaderStyle BackColor="#006699" Font-Bold="false" ForeColor="White" /&gt;
                           &lt;PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" /&gt;
                           &lt;RowStyle ForeColor="#000066" /&gt;
                           &lt;SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" /&gt;
                           &lt;SortedAscendingCellStyle BackColor="#F1F1F1" /&gt;
                           &lt;SortedAscendingHeaderStyle BackColor="#007DBB" /&gt;
                           &lt;SortedDescendingCellStyle BackColor="#CAC9C9" /&gt;
                           &lt;SortedDescendingHeaderStyle BackColor="#00547E" /&gt;
                     &lt;/asp:GridView&gt;
  </code></pre>