********************************<%@ Page Language="C#" AutoEventWireup="true" CodeFile="lingliao.aspx.cs" Inherits="wang_chuku_lingliao" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
 
        <asp:Label ID="Label1" runat="server" Text="佳盛领料系统" style="left: 363px; position: relative; top: 0px"></asp:Label>
        <hr/>
        <br />
        <asp:Label ID="Label2" runat="server" Font-Size="10pt" Style="left: 47px; position: relative;
            top: 0px" Text="编号:"></asp:Label>
        <asp:TextBox ID="bianhao2" runat="server" Font-Size="10pt" Style="left: 71px; position: relative;
            top: 0px"></asp:TextBox>
        <asp:Label ID="Label3" runat="server" Font-Size="10pt" Style="left: 108px; position: relative;
            top: -4px" Text="刀模类型:"></asp:Label>
        <asp:TextBox ID="leixin" runat="server" Style="left: 121px; position: relative; top: -1px"></asp:TextBox><br />
        <br />
        <asp:Label ID="Label4" runat="server" Font-Size="10pt" Style="left: 45px; position: relative;
            top: 0px" Text="计划:"></asp:Label>
        <asp:TextBox ID="jihua" runat="server" Font-Size="10pt" Style="left: 67px; position: relative;
            top: 0px"></asp:TextBox>
        <asp:Label ID="Label5" runat="server" Font-Size="10pt" Style="left: 132px; position: relative;
            top: -3px" Text="型体:"></asp:Label>
        <asp:TextBox ID="xingti" runat="server" Font-Size="10pt" Style="left: 148px; position: relative;
            top: 0px"></asp:TextBox><br />
        <br />
        <asp:Label ID="Label6" runat="server" Font-Size="10pt" Style="left: 33px; position: relative;
            top: 0px" Text="指示卡:"></asp:Label>
        <asp:TextBox ID="zhishika" runat="server" Font-Size="10pt" Style="left: 54px; position: relative;
            top: 0px"></asp:TextBox>
        <asp:Label ID="Label7" runat="server" Font-Size="10pt" Style="left: 119px; position: relative;
            top: -3px" Text="部位:"></asp:Label>
        <asp:TextBox ID="buwen" runat="server" Font-Size="10pt" Style="left: 136px; position: relative;
            top: -2px"></asp:TextBox><br />
        <br />
        <br />
        <asp:Button ID="Button1" runat="server" Style="left: 247px; position: relative; top: -5px"
            Text="搜索" OnClick="Button1_Click" />
        <asp:Button ID="Button2" runat="server" Style="left: 295px; position: relative; top: -6px"
            Text="重置" OnClick="Button2_Click" /><br />
        <br />
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
            BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
            CellPadding="3" CellSpacing="2" Font-Size="10pt" OnPageIndexChanging="GridView1_PageIndexChanging"
            OnRowCommand="GridView1_RowCommand" OnRowDataBound="GridView1_RowDataBound"
            Style="border-left-color: blue; page-break-before: auto; border-bottom-color: blue;
            page-break-after: auto; vertical-align: middle; overflow: scroll; width: 95%;
            border-top-color: blue; height: 20px; text-align: center; border-right-color: blue" OnRowCreated="GridView1_RowCreated">
            <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
            <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" Width="20px" />
            <Columns>
                <asp:BoundField DataField="DepositingID" HeaderText="编号"/>
                <asp:BoundField DataField="刀模类型" HeaderText="刀模类型" />
                <asp:BoundField DataField="进货时间" HeaderText="进货时间" />
                <asp:BoundField DataField="计划" HeaderText="计划" />
                <asp:BoundField DataField="型体" HeaderText="型体" />
                <asp:BoundField DataField="指示卡" HeaderText="指示卡" />
                <asp:BoundField DataField="部位" HeaderText="部位" />
                <asp:BoundField DataField="w3" HeaderText="3" />
                <asp:BoundField DataField="w3t" HeaderText="3t" />
                <asp:BoundField DataField="w4" HeaderText="4" />
                <asp:BoundField DataField="w4t" HeaderText="4t" />
                <asp:BoundField DataField="w5" HeaderText="5" />
                <asp:BoundField DataField="w5t" HeaderText="5t" />
                <asp:BoundField DataField="w6" HeaderText="6" />
                <asp:BoundField DataField="w6t" HeaderText="6t" />
                <asp:BoundField DataField="w7" HeaderText="7" />
                <asp:BoundField DataField="w7t" HeaderText="7t" />
                <asp:BoundField DataField="w8" HeaderText="8" />
                <asp:BoundField DataField="w8t" HeaderText="8t" />
                <asp:BoundField DataField="w9" HeaderText="9" />
                <asp:BoundField DataField="w9t" HeaderText="9t" />
                <asp:BoundField DataField="w10" HeaderText="10" />
                <asp:BoundField DataField="w10t" HeaderText="10t" />
                <asp:BoundField DataField="w11" HeaderText="11" />
                <asp:BoundField DataField="w11t" HeaderText="11t" />
                <asp:BoundField DataField="w12" HeaderText="12" />
                <asp:BoundField DataField="w12t" HeaderText="12t" />
                <asp:BoundField DataField="w13" HeaderText="13" />
                <asp:BoundField DataField="w14" HeaderText="14" />
                <asp:BoundField DataField="w15" HeaderText="15" />
                <asp:BoundField DataField="录入时间" HeaderText="录入时间" >
                    <ItemStyle Width="100px" />
                </asp:BoundField>
                <asp:BoundField DataField="录入人" HeaderText="录入人" />
                <asp:BoundField DataField="备注" HeaderText="备注" Visible="False" />
                <asp:TemplateField ShowHeader="False">
                    <ItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" CommandName="lingliao"
                            Text="领料" CommandArgument=<%#Eval("DepositingID")%>  ></asp:LinkButton>
<%--                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" CommandName="lingliao"
                            Text="领料" ></asp:LinkButton>--%>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
        </asp:GridView>
        <br />

解决方案 »

  1.   

    <asp:Panel ID="Panel1" runat="server" BackColor="#C0FFC0" Font-Size="10pt" Height="580px"
                Style="width: 95%" Visible="False" Width="125px">
                <br />
                <asp:Label ID="Label8" runat="server" Style="left: 287px; position: relative; top: 1px"></asp:Label><br />
                <br />
                <asp:Label ID="Label9" runat="server" Style="left: 23px; position: relative; top: 0px"
                    Text="刀模:"></asp:Label>
                <asp:TextBox ID="TextBox1" runat="server" Style="left: 28px; position: relative;
                    top: 0px" Width="125px"></asp:TextBox>
                <asp:Label ID="Label10" runat="server" Style="left: 46px; position: relative; top: 0px"
                    Text="计划:"></asp:Label>
                <asp:TextBox ID="TextBox2" runat="server" Style="left: 55px; position: relative;
                    top: 0px" Width="125px"></asp:TextBox>
                <asp:Label ID="Label11" runat="server" Style="left: 94px; position: relative; top: 0px"
                    Text="形体:"></asp:Label>
                <asp:TextBox ID="TextBox3" runat="server" Style="left: 118px; position: relative;
                    top: 0px" Width="125px"></asp:TextBox>
                <br />
                <br />
                <asp:Label ID="Label12" runat="server" Style="left: 10px; position: relative; top: -2px"
                    Text="指示长:"></asp:Label>
                <asp:TextBox ID="TextBox4" runat="server" Style="left: 12px; position: relative;
                    top: 0px" Width="125px"></asp:TextBox>
                <asp:Label ID="Label13" runat="server" Style="left: 26px; position: relative; top: 0px"
                    Text="部位:"></asp:Label>
                <asp:TextBox ID="TextBox5" runat="server" Style="left: 41px; position: relative;
                    top: 0px" Width="125px"></asp:TextBox>
                <asp:Label ID="Label14" runat="server" Style="left: 63px; position: relative; top: 0px"
                    Text="进货时间:"></asp:Label>
                <asp:TextBox ID="TextBox6" runat="server" Enabled="False" Style="left: 80px; position: relative;
                    top: 1px" Width="125px"></asp:TextBox>&nbsp;
                <br />
                <br />
                <asp:Label ID="Label31" runat="server" Style="left: 29px; position: relative; top: 0px"
                    Text="3:"></asp:Label><asp:TextBox ID="TextBox29" runat="server" Style="left: 29px;
                        position: relative; top: 0px" Width="100px"></asp:TextBox><asp:Label ID="Label15"
                            runat="server" Style="left: 64px; position: relative; top: 1px" Text="3T:"></asp:Label>
                <asp:TextBox ID="TextBox7" runat="server" Style="left: 59px; position: relative;
                    top: 1px" Width="100px"></asp:TextBox><asp:Label ID="Label16" runat="server" Style="left: 85px;
                        position: relative; top: 0px" Text="4:"></asp:Label><asp:TextBox ID="TextBox8" runat="server"
                            Style="left: 88px; position: relative; top: 0px" Width="100px"></asp:TextBox><asp:Label
                                ID="Label17" runat="server" Style="left: 130px; position: relative; top: 1px"
                                Text="4T:"></asp:Label><asp:TextBox ID="TextBox9" runat="server" Style="left: 130px;
                                    position: relative; top: 1px" Width="100px"></asp:TextBox>
                &nbsp;<br />
                <br />
                <asp:Label ID="Label18" runat="server" Style="left: 29px; position: relative; top: 0px"
                    Text="5:"></asp:Label><asp:TextBox ID="TextBox10" runat="server" Style="left: 29px;
                        position: relative; top: 0px" Width="100px"></asp:TextBox><asp:Label ID="Label19"
                            runat="server" Style="left: 59px; position: relative; top: 1px" Text="5T:"></asp:Label><asp:TextBox
                                ID="TextBox11" runat="server" Style="left: 59px; position: relative; top: 1px"
                                Width="100px"></asp:TextBox><asp:Label ID="Label20" runat="server" Style="left: 91px;
                                    position: relative; top: 0px" Text="6:"></asp:Label><asp:TextBox ID="TextBox12" runat="server"
                                        Style="left: 91px; position: relative; top: 0px" Width="100px"></asp:TextBox><asp:Label
                                            ID="Label21" runat="server" Style="left: 130px; position: relative; top: 1px"
                                            Text="6T:"></asp:Label><asp:TextBox ID="TextBox13" runat="server" Style="left: 130px;
                                                position: relative; top: 1px" Width="100px"></asp:TextBox><br />
                <br />
                <asp:Label ID="Label22" runat="server" Style="left: 29px; position: relative; top: 0px"
                    Text="7:"></asp:Label><asp:TextBox ID="TextBox14" runat="server" Style="left: 29px;
                        position: relative; top: 0px" Width="100px"></asp:TextBox><asp:Label ID="Label23"
                            runat="server" Style="left: 59px; position: relative; top: 1px" Text="7T:"></asp:Label><asp:TextBox
                                ID="TextBox15" runat="server" Style="left: 59px; position: relative; top: 1px"
                                Width="100px"></asp:TextBox><asp:Label ID="Label24" runat="server" Style="left: 91px;
                                    position: relative; top: 0px" Text="8:"></asp:Label><asp:TextBox ID="TextBox16" runat="server"
                                        Style="left: 91px; position: relative; top: 0px" Width="100px"></asp:TextBox><asp:Label
                                            ID="Label25" runat="server" Style="left: 130px; position: relative; top: 1px"
                                            Text="8T:"></asp:Label><asp:TextBox ID="TextBox17" runat="server" Style="left: 130px;
                                                position: relative; top: 1px" Width="100px"></asp:TextBox><br />
                <br />
                
      

  2.   

    <asp:Label ID="Label26" runat="server" Style="left: 29px; position: relative; top: 0px"
                    Text="9:"></asp:Label><asp:TextBox ID="TextBox18" runat="server" Style="left: 29px;
                        position: relative; top: 0px" Width="100px"></asp:TextBox><asp:Label ID="Label27"
                            runat="server" Style="left: 59px; position: relative; top: 1px" Text="9T:"></asp:Label><asp:TextBox
                                ID="TextBox19" runat="server" Style="left: 59px; position: relative; top: 1px"
                                Width="100px"></asp:TextBox><asp:Label ID="Label28" runat="server" Style="left: 85px;
                                    position: relative; top: -1px" Text="10:"></asp:Label><asp:TextBox ID="TextBox20"
                                        runat="server" Style="left: 85px; position: relative; top: -1px" Width="100px"></asp:TextBox><asp:Label
                                            ID="Label29" runat="server" Style="left: 119px; position: relative; top: 1px"
                                            Text="10T:"></asp:Label><asp:TextBox ID="TextBox21" runat="server" Style="left: 119px;
                                                position: relative; top: 1px" Width="100px"></asp:TextBox><br />
                <br />
                <asp:Label ID="Label30" runat="server" Style="left: 23px; position: relative; top: 0px"
                    Text="11:"></asp:Label><asp:TextBox ID="TextBox22" runat="server" Style="left: 23px;
                        position: relative; top: 0px" Width="100px"></asp:TextBox>
                <asp:Label ID="Label38" runat="server" Style="left: 46px; position: relative; top: -1px"
                    Text="11T"></asp:Label>
                <asp:TextBox ID="TextBox23"
                            runat="server" Style="left: 47px; position: relative; top: 1px" Width="100px"></asp:TextBox><asp:Label
                                ID="Label32" runat="server" Style="left: 64px; position: relative; top: -3px"
                                Text="12:"></asp:Label><asp:TextBox ID="TextBox24" runat="server" Style="left: 74px;
                                    position: relative; top: -1px" Width="100px"></asp:TextBox><asp:Label ID="Label33"
                                        runat="server" Style="left: 99px; position: relative; top: -4px" Text="12T:"></asp:Label><asp:TextBox
                                            ID="TextBox25" runat="server" Style="left: 106px; position: relative; top: -1px"
                                            Width="100px"></asp:TextBox><br />
                <br />
                <asp:Label ID="Label34" runat="server" Style="left: 23px; position: relative; top: 0px"
                    Text="13:"></asp:Label><asp:TextBox ID="TextBox26" runat="server" Style="left: 23px;
                        position: relative; top: 0px" Width="100px"></asp:TextBox><asp:Label ID="Label35"
                            runat="server" Style="left: 54px; position: relative; top: 1px" Text="14:"></asp:Label><asp:TextBox
                                ID="TextBox27" runat="server" Style="left: 54px; position: relative; top: 1px"
                                Width="100px"></asp:TextBox><asp:Label ID="Label36" runat="server" Style="left: 81px;
                                    position: relative; top: -6px" Text="15:"></asp:Label><asp:TextBox ID="TextBox28"
                                        runat="server" Style="left: 81px; position: relative; top: -6px" Width="100px"></asp:TextBox><br />
                <br />
                <asp:Label ID="Label37" runat="server" Style="left: 22px; position: relative; top: -80px"
                    Text="备注:"></asp:Label>
                <asp:TextBox ID="TextBox32" runat="server" Height="97px" Style="left: 31px; position: relative;
                    top: 0px" TextMode="MultiLine" Width="563px"></asp:TextBox><br />
                <br />
                <br />
                <asp:Button ID="Button3" runat="server" OnClick="Button1_Click" Style="left: 306px;
                    position: relative; top: -5px" Text="提交"  OnClientClick = "return confirm('确认领料吗?')" /><asp:Button ID="Button4" runat="server"
                        Style="left: 323px; position: relative; top: -5px" Text="重置" />
                <asp:Button ID="Button7" runat="server" OnClick="Button7_Click" Style="left: 347px;
                    position: relative; top: -4px" Text="关闭" /><br />
            </asp:Panel>
        </form>
    </body>
    </html>
      

  3.   

    ****************************然后,我运行,说我未将对象引用设置到对象的实例。 
    说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误: 
    行 148:        {
    行 149:            Button btn = e.Row.FindControl("LinkButton1") as Button;
    行 150:            btn.CommandArgument = e.Row.RowIndex.ToString();
    行 151:        } 
    行 152:    }
     源文件: g:\项目方案\小敏敏的仓库管理系统\Jiasheng\wang\chuku\lingliao.aspx.cs    行: 150 堆栈跟踪: 
    [NullReferenceException: 未将对象引用设置到对象的实例。]
       wang_chuku_lingliao.GridView1_RowCreated(Object sender, GridViewRowEventArgs e) in g:\项目方案\小敏敏的仓库管理系统\Jiasheng\wang\chuku\lingliao.aspx.cs:150
       System.Web.UI.WebControls.GridView.OnRowCreated(GridViewRowEventArgs e) +105
       System.Web.UI.WebControls.GridView.CreateRow(Int32 rowIndex, Int32 dataSourceIndex, DataControlRowType rowType, DataControlRowState rowState, Boolean dataBind, Object dataItem, DataControlField[] fields, TableRowCollection rows, PagedDataSource pagedDataSource) +136
       System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +2957
       System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +59
       System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable data) +11
       System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +111
       System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +29
       System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
       System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
       System.Web.UI.WebControls.GridView.DataBind() +4
       wang_chuku_lingliao.show() in g:\项目方案\小敏敏的仓库管理系统\Jiasheng\wang\chuku\lingliao.aspx.cs:52
       wang_chuku_lingliao.Page_Load(Object sender, EventArgs e) in g:\项目方案\小敏敏的仓库管理系统\Jiasheng\wang\chuku\lingliao.aspx.cs:42
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
       System.Web.UI.Control.OnLoad(EventArgs e) +99
       System.Web.UI.Control.LoadRecursive() +47
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436 
    --------------------------------------------------------------------------------
    版本信息: Microsoft .NET Framework 版本:2.0.50727.1433; ASP.NET 版本:2.0.50727.1433 ************************因为我是看到您在
    http://topic.csdn.net/u/20070723/10/0d5dcb02-263d-40cf-879e-868afda61925.html教我们用
                    protected   void   GridView1_RowCreated(object   sender,   GridViewRowEventArgs   e) 
                    { 
                            if   (e.Row.RowType   ==   DataControlRowType.DataRow) 
                            { 
                                    Button   btn   =   e.Row.FindControl( "btnDel ")   as   Button; 
                                    btn.CommandArgument   =   e.Row.RowIndex.ToString(); 
                            } 
                    }请问,我错在那里了呢?        string type = e.CommandName.ToString().Trim();可以获取
      

  4.   

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using Model;
    using SQLServerDAL;
    using BLL;public partial class wang_chuku_lingliao : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {        string quanxian = Session["quanxian"].ToString().Trim();//判断用户组
            if (quanxian.Equals("管理员") || quanxian == "管理员")
            {        }
            else if (quanxian.Equals("入库") || quanxian == "入库")
            {        }
            else
            {
                Response.Write("<script>alert(\"对不起!你的权限无法进入该页面,请与管理员联系!\")</script>");
                string temp_url = System.Configuration.ConfigurationSettings.AppSettings["tree"].ToString();
                temp_url = temp_url + "Login.aspx";
                Response.Redirect(temp_url);
            }
            //if (!Page.IsPostBack)
            //{
                show();
            //}    }
            //载入数据 (默认数据)
        public void show() 
        {            S_Depositing sd = new S_Depositing();
                this.GridView1.DataSource = sd.get_Depositing_time();
                this.GridView1.DataBind();    }    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            this.GridView1.PageIndex = e.NewPageIndex;
            this.GridView1.DataBind();
        } 
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string type = e.CommandName.ToString().Trim();
            int row = Convert.ToInt32(e.CommandArgument);
            if(type.Equals("lingliao")||type=="lingliao")
            {
                //Response.Write("<script>alert(\"领料\");</script>");
                if (this.Panel1.Visible)
                {
                    this.Panel1.Visible = false;
                }
                else 
                {
                    this.Panel1.Visible = true;
                    this.GridView1.Rows[row].BackColor = System.Drawing.Color.Sienna;
                }        }
        }
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //鼠标经过row时的效果
                e.Row.Attributes.Add("onmouseover", "e=this.style.backgroundColor; this.style.backgroundColor='b2c5eb'");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=e");
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            //搜索
            string 编号 = this.bianhao2.Text;
            string 刀模类型 = this.leixin.Text;
            string 计划 = this.jihua.Text;
            string 型体 = this.xingti.Text;
            string 指示卡 = this.zhishika.Text;
            string 部位 = this.buwen.Text;
            if (编号 == "" && 刀模类型 == "" && 计划 == "" && 指示卡 == "" && 部位 == "" && 型体 == "")
            {
                show();
            }
            else 
            {            B_Depositing bd = new B_Depositing();
                System.Data.DataSet sds = bd.get_Depositing_select(编号, 刀模类型, 计划, 指示卡, 部位, 型体);
                this.GridView1.DataSource = sds;
                this.GridView1.DataBind();        }
        }
        protected void Button7_Click(object sender, EventArgs e)
        {    }    //protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
        //{
        //    //在RowCreated事件中添加 
        //      //e.Row.Cells[0].Attributes.Add("style", "word-break :break-all ; word-wrap:break-word"); 
        //    if (e.Row.RowType == DataControlRowType.DataRow)
        //    {
        //        Button btn = e.Row.FindControl("lingliao") as Button;
        //        btn.CommandArgument = e.Row.RowIndex.ToString();
        //    }     //}    protected void bianhao_TextChanged(object sender, EventArgs e)
        {
            //将搜索的清空
            this.bianhao2.Text = "";
            this.leixin.Text = "";
            this.jihua.Text = "";
            this.xingti.Text = "";
            this.zhishika.Text = "";
            this.buwen.Text = "";
        }
        protected void Button2_Click(object sender, EventArgs e)
        {    }
        protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Button btn = e.Row.FindControl("LinkButton1") as Button;
                btn.CommandArgument = e.Row.RowIndex.ToString();
            } 
        }
    }
      

  5.   

    事件写错了,应该是GridView1_RowDataBound下次不要贴这么多代码,看着晕,贴关键就可以了