How to retrieve the particular row of detailsview into textbox on page load event if details view defaultmode is readonly
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
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;
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)