1 在这个控件中我加一个空列.在里面放了一个TextBox并绑定了他的值 ,在EditItemTemplate 里也放了一个TextBox 也绑定了值 ,,,可在更新时就不能正常的更新,,,数据为空..没有得到 自定列的值(这列的名为a)
2 在里面还有两个删除 button 我想在点不同的button 时执行不同的SQL语句 我该怎样呀

解决方案 »

  1.   

    看MSDN去。。这问题懒的说 了
      

  2.   

    1 给出你详细的代码2 利用按钮的commandname 或者按钮列的命令名称,然后在rowcommand事件里面
    if(e.commandname == 按钮的commandname )
    {}
    ...类似这样的判断按钮以及写处理方法
      

  3.   

    protected void Page_Load(object sender, EventArgs e)
    }
    if(!IsPostBack)
    {}
    }给两个Button其CommandName起名字
      

  4.   

    <asp:GridView ID="GridView2" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                DataKeyNames="id" DataSourceID="SqlDataSource1" OnDataBound="GridView2_DataBound"
                OnRowDataBound="GridView2_RowDataBound" OnRowDeleting="GridView2_RowDeleting"
                Width="598px" OnRowCommand="GridView2_RowCommand">
                <Columns>
                    <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True"
                        SortExpression="id" />
                    <asp:BoundField DataField="keyword" HeaderText="关键字" SortExpression="keyword" />
                    <asp:BoundField DataField="content" HeaderText="说明文字" SortExpression="content" />
                    <asp:BoundField DataField="topPrice" HeaderText="当前价格" SortExpression="topPrice" />
                    <asp:BoundField DataField="title" HeaderText="标题" SortExpression="title" />
                    <asp:BoundField DataField="url" HeaderText="URL" SortExpression="url" />
                    <asp:CommandField DeleteText="通过" HeaderText="通过" ShowDeleteButton="True" />
                    <asp:CommandField DeleteText="拒绝" HeaderText="拒绝" ShowDeleteButton="True" ShowHeader="True" />
                </Columns>
            </asp:GridView>
      

  5.   

    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                DataKeyNames="id" DataSourceID="SqlDataSource2" Width="598px">
                <Columns>
                    <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True"
                        SortExpression="id" />
                    <asp:BoundField DataField="Keyword" HeaderText="Keyword" SortExpression="Keyword" />
                    <asp:BoundField DataField="Hits" HeaderText="Hits" SortExpression="Hits" />
                    <asp:BoundField DataField="LastUpdate" HeaderText="LastUpdate" SortExpression="LastUpdate" />
                    <asp:BoundField DataField="Class" HeaderText="Class" SortExpression="Class" />
                    <asp:TemplateField HeaderText="qq">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Keyword") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Keyword") %>'></asp:TextBox>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:CommandField ShowEditButton="True" />
                </Columns>
            </asp:GridView>这个是  更新值 没更新成功的
      

  6.   

    ,在EditItemTemplate 里也放了一个TextBox 也绑定了值 ,,,可在更新时就不能正常的更新,,,数据为空..没有得到 自定列的值(这列的名为a)
    -------------------------你给的代码并未有上面这段话里面的模版列啊?
      

  7.   

    怎么会有两个gridview了?究竟两个有什么区别了?
      

  8.   

    更新的SQL语句 UPDATE Keyword SET Keyword = @qq  WHERE (id = @id)
      

  9.   

    更新值在相应的更新方法里面用
    TextBox tbqq =(TextBox)e.row.FindControl("TextBox3");来取得更新现在我只能说这些,不知道你的后台代码是如何处理的
      

  10.   

    如果你用的是sqldatasource的更新,怎么没看到相应的updatecommand?如果你用的是sql语句更新,那么就是用我上面的方法来得到修改后的字符串
    忘记写
    string  newqq = tbqq.Text;
      

  11.   

    jimu8130(火箭的未来在哪里?) 是在哪个事件里呀
      

  12.   

    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
             这里没有e.row.FindControl("TextBox3") 
              只有e.RowIndex
        }
      

  13.   

    e.NewValues-------这个嘛,你自己要动手嘛。不过我都是用sql字符串来更新我一般都会加个编辑更新按钮列,然后在updatecommand进行对更新进行处理
      

  14.   

    在里面还有两个删除 button 我想在点不同的button 时执行不同的SQL语句?如果是linkbutton就很好办了,采用不同CommandName值就可以执行不同的语句