计算机型号............. OptiPlex 990 系统类型............... x64-based $ 这里:Operationg系统,这些版本是列 Microsoft Windows 7 Professional,6.1.760l这些是数据表中的第一行,同时其他记录也动态添加到数据表中作为列。 这里动态地将列添加到datatable。 问题是我想增加动态添加列的列宽。 如何解决这个问题。 请任何人帮助我。Example : Name ...................... IICSS21Operating System ............. Microsoft Windows 7 ProfessionalVersion .............. 6.1.7601Manufacturer ............. Microsoft CorporationComputer Name ............. IICSS21Windows Directory ............. C:\WindowsSerial Number ............. 00371-OEM-9203635-37779ComputerManufacturer Name ............. Dell Inc.Computer Model ............. OptiPlex 990System Type ............. x64-based PChere : Operationg system, Version like these are the columns Microsoft Windows 7 Professional,6.1.760l these are the first row in datatable and same time other records also added dynamically to datatable as columns.Here dynamically added the columns to datatable.Problem is i want to increase the column width for dynamically added columns.How can do this problem.Please any one help me.推荐答案您好, 从以下代码中获取知识:Hi,Take knowledge from this below code :protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e){ System.Data.DataRowView drv; drv = (System.Data.DataRowView)e.Row.DataItem; if (e.Row.RowType == DataControlRowType.DataRow) { if (drv != null) { String catName = drv[1].ToString(); Response.Write(catName + "/"); int catNameLen = catName.Length; if (catNameLen > widestData) { widestData = catNameLen; GridView1.Columns[2].ItemStyle.Width = widestData * 30; GridView1.Columns[2].ItemStyle.Wrap = false; } } }} 如果没有解决,请点击此处: http://msdn.microsoft.com/en-us /library/ms178296(v=vs.100).aspx [ ^ ] 如果要包装单元格内容然后点击此处: http://myaspsnippets.blogspot.in/ 2011/01 /那是偶然的,当一个人可能工作的时候...... [ ^ ] 这篇关于如何在asp.net中为gridview动态添加列宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-23 02:58