你是想获的e.item这行的值吗
可以取得e.item.cell(i)的关键字,再给sql查询一次
或者取得e.item这行后,传给变量。

解决方案 »

  1.   

    tryDataGrid.Items[DataGrid.EditItemIndex]
      

  2.   

    问题是Update_Command 事件 与 Edit_Command 事件中所传的参数 e 是不同的在Update_Command 事件中 e.item 是EditItemTemplate
    而Edit_Command 事件中  e.item 是ItemTemplate这是不同的!现在我要在 非Update_Command 事件中得到EditItemTemplate中的内容,这该怎样做???
      

  3.   

    this.DataGrid1.EditItemIndex 是当前编辑的行
    e.Item.Cells[0].Text  便是当前行第一列TextBox中的值.
      

  4.   

    e不同没关系.你要的不是e,而是e.Item.Index,而这是一样的
      

  5.   

    我在Datagrid中加了一个模板列,在EditItemTemplate中加了一个DropDownList我现在要实现的是当点击“修改”时,绑定DropDownList。
    就是修改的时候“政治面貌”下拉选择的。以下是 Html  部分
    <asp:DataGrid id="dgFamily" runat="server" Width="661px" AllowSorting="True" AutoGenerateColumns="False" ShowFooter="True">
    <Columns>
    <asp:TemplateColumn SortExpression="ZZMM" HeaderText="政治面貌">
    <HeaderStyle Width="100px"></HeaderStyle>
    <ItemTemplate>
    <FONT face="宋体">
    <asp:Label id=Label10 runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ZZMM") %>'>
    </asp:Label></FONT>
    </ItemTemplate>
    <FooterTemplate>
    <FONT face="宋体">
    <asp:DropDownList id="DropDownList2" runat="server"></asp:DropDownList></FONT>
    </FooterTemplate>
    <EditItemTemplate>
    <FONT face="宋体">
    <asp:DropDownList id="Dropdownlist3" runat="server"></asp:DropDownList></FONT>
    </EditItemTemplate>
    </asp:TemplateColumn> <asp:TemplateColumn>
    <HeaderStyle Width="40px"></HeaderStyle>
    <ItemTemplate>
    <FONT face="宋体">
    <asp:LinkButton id="Linkbutton5" runat="server" CommandName="Edit">修改</asp:LinkButton></FONT>
    </ItemTemplate>
    <FooterTemplate>
    <FONT face="宋体">
    <asp:LinkButton id="Linkbutton6" runat="server" CommandName="Add">添加</asp:LinkButton></FONT>
    </FooterTemplate>
    <EditItemTemplate>
    <FONT face="宋体">
    <asp:LinkButton id="Linkbutton7" runat="server" CommandName="Update">更新</asp:LinkButton>
    <asp:LinkButton id="Linkbutton8" runat="server" CommandName="Cancel">取消</asp:LinkButton></FONT>
    </EditItemTemplate>
    </asp:TemplateColumn> </Columns>
    </asp:DataGrid>
      

  6.   

    虽然在Update_Command 事件中Edit_Command 事件中 e.item.ItemIndex 是一样的,但是e.item.itemType 是不一样的!!!!!Update_Command 事件中 e.item.itemType=ListItemType.EditItem
    Edit_Command 事件中  e.item.itemType=ListItemType.Item
      

  7.   

    如果你非要这样做的话,你可以将两个控件都放到一起,然后控制他们的Visible属性
      

  8.   

    第一步:设置EditItemIndex、设置DataSource、执行DataBind()
    第二步:用DataGrid1.Items[DataGrid1.EditItemIndex].FindControl来查找控件