如何从DevExp AspxGridview获取选定的行

时间:2014-06-05 12:04:46

标签: c# asp.net devexpress aspxgridview autopostback

当用户点击屏幕上的“SEÇ”(“SELECT”)按钮时,我试图从aspxgridview中获取所选行。如下所示。

当用户单击SEC按钮时,它会提供空引用异常

出错了什么?

这是我的代码......

protected void btnClose0_Click(object sender, EventArgs e)
    {
        try
        {
            string cari_logref = gvCari.GetDataRow(gvCari.FocusedRowIndex)["LOGICALREF"].ToString();

            dtneww = ListTable(Convert.ToInt16(cari_logref));
            gv.DataSource = dtneww;
            gv.DataBind();
        }
        catch (Exception)
        { }
    }

enter image description here

1 个答案:

答案 0 :(得分:0)

您正在尝试使用FocusedRowIndex检索焦点行,您想要的是不同的GetSelectedFieldValues,请参阅:https://documentation.devexpress.com/#AspNet/DevExpressWebASPxGridViewASPxGridView_GetSelectedFieldValuestopic