Cómo recuperar la fila particular de vista de detalles en el cuadro de texto en el evento de carga de la página si el modo predeterminado de vista de detalles es de solo lectura

How to retrieve the particular row of detailsview into textbox on page load event if details view defaultmode is readonly

texto alternativo

i want to retrieve the email id from detailsview email row in textbox1 on page load event ?

preguntado el 09 de enero de 11 a las 09:01

Show us your code, explain what isn't working and what you are having difficulties with. -

2 Respuestas

One way is to access the DataItem in the RowDataBound like:

DataRowView dr = (DataRowView)DetailsView1.DataItem;
string myfield = (string)dr["YourFieldName"];

Another way is get the item from Rows.Cells me gusta:

DetailsViewRow row = DetailsView1.Rows[youremailrowindex];
String email= row.Cells[youremailcellindex].Text;

Respondido el 09 de enero de 11 a las 21:01

Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
    TextBox1.Text = DetailsView1.Rows(2).Cells(1).Text
End Sub

Make sure you realize that with a DetailsView, the max "Cells" value is 1. Look at it as if you were pulling and SQL query and these are the rows that are output.

Row = Up and down (starting with 0)

Cells = Column (0 or 1)

Respondido 04 Abr '12, 21:04

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.