Accessing unbound DetailsView cell values when Detailsview DefaultMode is Edit

Posted by Nickson on Stack Overflow See other posts from Stack Overflow or by Nickson
Published on 2010-04-12T08:50:48Z Indexed on 2010/04/12 8:53 UTC
Read the original article Hit count: 508

Filed under:
|

i have a DetailsView that is populated by a Linq to Entities query. Example query is below.

Dim Record = From L In db.MyRecords _

            Where L.RecordID = 100 _

            Select ID = L.RecordID,  L.column1, L.column2, L.column3, L.column4

    DetailsView2.DataSource = Record

    DetailsView2.DataBind()

The defaultMode for the DetailsView is Edit. Now if this Detailsview was bound to a datasource control, i would convert a column to a templateColumn and programatically access cell values like so

Dim NameTextBox As System.Web.UI.WebControls.TextBox = CType(DetailsView2.Rows(1).Cells(1).FindControl("TextBox1"), System.Web.UI.WebControls.TextBox)

such that i can then say NameTextBox.Text to get the Name value.

But the problem i have is, with this detailsview which is unbound, i have no column at design time to convert to a template, and yet i want to access its cell values. help is appreciated.

© Stack Overflow or respective owner

Related posts about detailsview

Related posts about ASP.NET