Formview current Row

  • Thread starter Karl-Inge Reknes
  • Start date
K

Karl-Inge Reknes

Can anybody tell me how I can get an column from current row from
code-behind, C#.

The formview is connected to an objectdatasource.

Karl-Inge
 
P

Phillip Williams

Hi Karl-Inge,

You can find a control within the FormViewRow by using the FindControls
method, e.g. if you have an EditItemTemplate with a dropdownlist in it you
can refer to it like this:
DropDownList ddl =
((DropDownList)(FormView)sender).FindControl("DropDownList1");
 
K

Karl-Inge Reknes

Thanks Phillip

Karl-Inge

Phillip Williams said:
Hi Karl-Inge,

You can find a control within the FormViewRow by using the FindControls
method, e.g. if you have an EditItemTemplate with a dropdownlist in it you
can refer to it like this:
DropDownList ddl =
((DropDownList)(FormView)sender).FindControl("DropDownList1");
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
 
K

Karl-Inge Reknes

Hi Phillip

Your answare lead me into a another solution:

String CustomerName = ((Customer)FormView)sender).CustomerName;

Where Customer is the class (List<Customer>) that is return by the
objectdatasource to the formview control, and CustomerName is a property of
the Customer class.

Thanks again!

Karl-Inge
 
K

Karl-Inge Reknes

Hi Phillip

The solution I found has wrong code. Her is the corret code:

string customerName =
((Customer)((FormView)((DropDownList)sender).NamingContainer).DataItem).CustomerName;

Where Customer is the class (List<Customer>) that is return by the
objectdatasource to the formview control, and CustomerName is a property of
the Customer class.


Karl-Inge
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,132
Latest member
TeresaWcq1
Top