用AutoGenerateColumns = true操作GridView中的列的任何方法?
<asp:GridView class='gvTable' ID='grd' runat='server' AutoGenerateColumns="true" OnRowDataBound="grd_RowDataBound">
asp:TemplateField
编辑
<asp:Image ID='btn_Edit' ImageUrl='../Image/ButtonEdit_1.gif' CssClass='Edit' runat='server'/>
            </ItemTemplate>
        </asp:TemplateField>
     </Columns>
  </asp:GridView>
protected void grd_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[0].Attributes.Add("datakey", e.Row.Cells[1].Text);
DataRowView row = (DataRowView)e.Row.DataItem;
string s = row["分类"].ToString();
if (row["分类"].ToString() == "2到货计划	")
{
            }
            else {
                e.Row.Cells[0].Text = "";
            }
        }
        
        e.Row.Cells[1].Visible = false;
    }
                    
                
                
            
        
浙公网安备 33010602011771号