문제

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!

도움이 되었습니까?

해결책

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";
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top