<ItemTemplate>
<asp:LinkButton id=lbPre26 runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "PreviousMonth26") %>' Height="100%" Width="100%" CommandName="Edit" CommandArgument="0"></asp:LinkButton>
</ItemTemplate>
在DataGrid1_EditCommand中由e.CommandArgument是否等于“0”可以判断是否是这列,
(int)e.Item.ItemIndex + (DataGrid1.CurrentPageIndex)*(DataGrid1.PageSize)是点击行

解决方案 »

  1.   

    如果DataGrid的第0列为其关键字段,
    string sKey = DataGrid1.SelectedItem.Cells[0].Text;
    string sSql = "Select * From YourTable Where yourKeyField = '" + sKey + "'";
      

  2.   

    1.如果你需要获取的那一列是Key的话,可以设置DataGrid的DataKeyField属性为此PK字段,
    然后可以通过this.DataGrid1.DataKeys[this.DataGrid1.SelectedIndex];来获取Key值。
    2.如果是其他情况,可以使用morality(逆水行舟,勇进)所说的方法。
      

  3.   

    string strValue = DataGrid.SelectedItem.Cells[0].Text;
      

  4.   

    e.Item.Cells[0].Text;
    这样可以把主键取出来。如果0列是主键的话。然后把这个值放到 查询语句中。
      

  5.   

    看你是在客户端用还是服务端用,
    服务端用:e.Item.Cells[0].Text;
    客户端用:先在服务端增加单击事件,然后在客户端得到数据
    Private Sub dg_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dg.ItemCreated
     e.Item.Attributes.Add("onclick", "Jscript:myclick(" & e.Item.ItemIndex & ")")
     End Sub然后在客户端
    sub myclick(r)
    dim a
    a=dg.rows(r).cells(0).innertext
    end sub
      

  6.   

    首先感谢各位,其次我想再说明一下,我为了达到某些功能使用了Infragistics控件(一种第三方控件),使用C#语言,它既没有SelectedItem也没有DataKeyField。如果哪位使用过Infragistics,请给出在此控件的解决方法。
    感谢!!
      

  7.   

    这个控件没用过,不过应该和Datagrid差不多吧,