在DataGrid中 ,编辑按钮,删除按钮已用的情况下,如何用选择按钮或链接列实现更新一天数据??具体情况如下:在绑定的数据中,有一个状态值(用2、1、0表示),现在我要通过点击选择按钮或链接列实现其数据的更新(选择后要进行判断,如:在数据为0是才可以更新),现在我的问题是怎么样取到GataGrid中某一行某一列的值(非DataKeyField字段,普通列)

解决方案 »

  1.   

    <asp:datagrid id="DataGrid1" runat="server" AutoGenerateColumns="False" Width="100%" ForeColor="Black" OnItemCommand="item_command" BorderColor="#999999"> <Columns>
               <asp:TemplateColumn HeaderText="堆叠">             <ItemTemplate>
         <asp:ImageButton ID="Imagebutton4" Runat="server" CommandName="Item_dd" ImageUrl="../../images/find.gif"></asp:ImageButton>
               </ItemTemplate>
    </asp:TemplateColumn>
    ......'代码
      Sub item_Command(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
            Select Case (CType(e.CommandSource, ImageButton)).CommandName
               Case "Item_dd"
                    Dim yy = CType(e.Item.FindControl("bh"), Label).Text
                    Response.Write("<script>window.open('dd_qk.aspx?yy=" + yy + "','yy','toolbar=no,resizable=yes,width=650,height=380')</script>")
                     fillgrid()
                Case Else
                    ' Do nothing.        End Select    End Sub
      

  2.   

    '忘了判断,修改如下,你还要自己修改一下 
    Sub item_Command(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
            Select Case (CType(e.CommandSource, ImageButton)).CommandName
               Case "Item_dd"
                  if CType(e.Item.FindControl("要判断的字段"), Label).Text
                    Dim yy = CType(e.Item.FindControl("bh"), Label).Text
                    Response.Write("<script>window.open('dd_qk.aspx?yy=" + yy + "','yy','toolbar=no,resizable=yes,width=650,height=380')</script>")
                     fillgrid()
                  end if
                Case Else
                    ' Do nothing.        End Select    End Sub