我想修复gridview的宽度。我正在填充gridview如下;
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();
这里 dgvTumİsler 是我的网格视图。我尝试了以下代码来制作固定长度。但它不起作用;
for (int i = 0; i < dgvTumIsler.Columns.Count; i++)
{
dgvTumIsler.Columns[i].ItemStyle.Width = 100;
}
这里 dgvTumİsler.Columns.Count 的值为 1。所以它不起作用。有没有办法解决这个问题,或者有没有另一种方法可以让 gridview 固定宽度。
HTML 代码:
<asp:GridView ID="dgvTumIsler" runat="server" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" OnSelectedIndexChanged="dgvTumIsler_SelectedIndexChanged">
<Columns>
<asp:CommandField ButtonType="Button" SelectText="Seç" ShowCancelButton="False" ShowSelectButton="True" />
</Columns>
<FooterStyle BackColor="White" ForeColor="#000066" />
<HeaderStyle BackColor="#006699" Font-Bold="false" ForeColor="White" />
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
<RowStyle ForeColor="#000066" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#007DBB" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#00547E" />
</asp:GridView>