Question

How can I update the text of a detailsview boundfield in edit or insert mode from a button click?

I have a detailsview edit / insert form and a FileUpload control on the same page. Whilst in edit or insert mode I'd like to be able to upload a PDF and change one of the detailsview controls text to the PDF path.

Something like:

protected void Button1_Click(object sender, EventArgs e)
{
    if (DetailsView1.CurrentMode == DetailsViewMode.Insert)
    {
        DetailsView1.FindControl("attachment").text = FilePath;

    }
}

Thanks!

Was it helpful?

Solution

I think you should typecast the control you are searching for into the desired type of control, like:

TextBox Check=DetailsView1.FindControl("attachment") as TextBox;

then you should try to either get or set its value. Like:

Check.text="Something";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top