Vy Clarks Vy Clarks - 3 years ago 591
ASP.NET (C#) Question

How to get field value of selected Row Devexpress GridView?

I use a DevexpressGridView to display all

TOPIC (id,title,content)


<dx:ASPxGridView ID="gv" runat="server"
OnSelectionChanged="gv_SelectionChanged" >


I have grid_SelectionChanged event:

protected void gv_SelectionChanged(object sender, EventArgs e)
{

int id= selected row...???; //how can I get the value of selected row
string sql = "select * from TOPIC where idTOPIC="+id;
DataTable topic = l.EXECUTEQUERYSQL(sql);
TextBox1.Text = topic.Rows[0][1].ToString();
}


...

It seems
gv.SelectedRow
method isn't exist in DevGridview.

As recommended, I've tried with
FocusedRowIndex
method, but I really dont know the right syntax to get the value of selected row.

Help!!!

Answer Source

I've found my answere here after a long time searching google: http://www.devexpress.com/Support/Center/Question/Details/Q347704

Use the ASPxGridView.GetSelectedFieldValues method get selected row values on the server side.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download