views:

685

answers:

1

Hi,

I'd like to know if it is possible to set a field of a DetailsView BoundField (in edit mode) from javascript? I can't set an id for the boundfield, so obviously can't use document.getElementById() to get to it, but I was wondering if there's another way to do it?

+1  A: 

You could try to create an EditItemTemplate, place a TextBox inside and give it an ID of your choice.

Like this:

<Fields>
        <asp:TemplateField HeaderText="Column1">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            </EditItemTemplate>
        </asp:TemplateField>
    </Fields>

If there is stuff to be bound on the TextBox's Text property you could use Bind() method.

Good Luck.

Maxime