你是不是在itemdatabound事件里操作?
解决方案 »
- 谁来给个服务器端控件css样式的对应关系
- 请教两则小问题
- 怎么输出曲面图?调用excel生成曲面图后,怎么把里面的图表另存成图片?
- GridView字段隐藏掉没值问题,请高手指点!
- B/S和C/S混合架构
- vs2003.net不能新建和打开asp.net应用程序,求助大家解决!!!!
- ASP.NET的命令提交問題,就決就給分!哈
- 如何用session判断一个用户已离开,在global.asax里的Session_End用if (Session["user"]==null){...}好像不行
- 初学.net,有关于数据库连接问题,请帮忙!
- 怎样上传html文件?
- 求一个vs2005中menu控件绑定数据库或者xml的例子 谢谢~~~~
- petshop是什么东西,和asp.net有什么关系
BackColor="White" BorderColor="#3366CC" BorderStyle="Solid" BorderWidth="1px"
CellPadding="2" Font-Size="12px" HorizontalAlign="Left" OnPageIndexChanging="gvComUnion_PageIndexChanging"
OnRowEditing="gvComUnion_RowEditing" PageSize="12" Width="545px" OnRowDataBound="gvComUnion_RowDataBound" OnLoad="gvComUnion_Load" OnRowCreated="gvComUnion_RowCreated" Font-Names="宋体" OnSelectedIndexChanged="gvComUnion_SelectedIndexChanged" AllowSorting="True" >
<PagerSettings FirstPageText="第一页" LastPageText="最后一页" Mode="NextPreviousFirstLast"
NextPageText="下一页" PreviousPageText="上一页"/>
<FooterStyle BackColor = "#EFEFEF" ForeColor = "#000D47"/>
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID">
<ItemStyle HorizontalAlign="Left"/>
<HeaderStyle Width="30px"/>
</asp:BoundField>/////--------------------第一列
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="ckbSelect" runat="server" Text="全选" OnCheckedChanged="CheckAll" Width="40px" AutoPostBack="True"/>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="ItemCheckBox" runat="server" />
</ItemTemplate>
</asp:TemplateField>/////--------------------第二列 <asp:BoundField DataField="COMID" HeaderText="编号">
<ItemStyle HorizontalAlign="Left" />
<HeaderStyle Width="30px" />
</asp:BoundField>
<asp:BoundField DataField="COMNAME" HeaderText="单位名称">
<ItemStyle HorizontalAlign="Left" />
<HeaderStyle Width="100px" />
</asp:BoundField>
<asp:BoundField DataField="COMINLOW" HeaderText="所有制">
<ItemStyle HorizontalAlign="Left" />
<HeaderStyle Width="90px" />
</asp:BoundField>
<asp:BoundField DataField="BUSINESS" HeaderText="行业">
<ItemStyle HorizontalAlign="Left" />
<HeaderStyle Width="90px" />
</asp:BoundField>
<asp:BoundField DataField="DISTRICT" HeaderText="所在区">
<ItemStyle HorizontalAlign="Left" />
<HeaderStyle Width="40px" />
</asp:BoundField>
<asp:BoundField DataField="STATUS" HeaderText="状态">
<ItemStyle HorizontalAlign="Left" />
<HeaderStyle Width="30px" />
</asp:BoundField>
<asp:CommandField EditText="详细信息" HeaderText="详细信息" ShowEditButton="True">
<HeaderStyle Width="60px" />
</asp:CommandField> </Columns> <RowStyle ForeColor="#003399" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCFF99" />
<PagerStyle BackColor="#EFEFEF" ForeColor="#003399" HorizontalAlign="Right" />
<HeaderStyle BackColor="#003399" BorderStyle="None" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="#EFEFEF" />
</asp:GridView>
这样写的,运行后始终看不到第一列。
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#FFEFD5'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor"); }
if (e.Row.RowType == DataControlRowType.DataRow)
{
if ((e.Row.Cells[3].Text).Length > 8 && (e.Row.Cells[3].Text!=" "))
{
e.Row.Cells[3].Text = (e.Row.Cells[3].Text).Substring(0, 8) + "...";
}
if ((e.Row.Cells[4].Text).Length > 6 && (e.Row.Cells[4].Text != " "))
{
e.Row.Cells[4].Text = (e.Row.Cells[4].Text).Substring(0, 6) + "...";
}
if ((e.Row.Cells[5].Text).Length > 6 && (e.Row.Cells[5].Text!=" "))
{
e.Row.Cells[5].Text = (e.Row.Cells[5].Text).Substring(0, 6) + "...";
}
}
}
有什么问题吗?
在 protected void gvComUnion_RowDataBound(object sender, GridViewRowEventArgs e)
加一句
e.Row.Cells[0].Visible = true;
就能显示了,问题是为什么不加就不能显示啊?
我们一起创业,我们一起发财,我们一起快乐,我们一起努力!