简体   繁体   English

ASP.NET从javascript设置DetailsView BoundField值

[英]ASP.NET Setting a DetailsView BoundField value from javascript

I'd like to know if it is possible to set a field of a DetailsView BoundField (in edit mode) from javascript? 我想知道是否可以从javascript设置DetailsView BoundField的字段(在编辑模式下)? 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? 我无法为边界字段设置ID,因此显然不能使用document.getElementById()来获取它,但是我想知道是否还有另一种方法?

You could try to create an EditItemTemplate, place a TextBox inside and give it an ID of your choice. 您可以尝试创建一个EditItemTemplate,在其中放置一个TextBox并为其指定一个ID。

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. 如果在TextBox的Text属性上有绑定的内容,则可以使用Bind()方法。

Good Luck. 祝好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM