简体   繁体   English

使用ASP.net将可编辑框扩展到detailsview表的末尾

[英]Extending the editable box to the end of the detailsview table, using ASP.net



I am currently tasked to do a SQL database with web interface. 我目前的任务是使用Web界面执行SQL数据库。 I am using the Microsoft Visual Web Developer 2010 Express to develop the prototype. 我正在使用Microsoft Visual Web Developer 2010 Express开发原型。

My question is, using the detailsview to edit the user information, how do I make the editable text box to be extended to the end of the table? 我的问题是,使用detailsview编辑用户信息,如何使可编辑文本框扩展到表的末尾? If possible, the text box can extend downwards with excess text wrapped. 如果可能的话,文本框可以向下延伸,并包裹多余的文本。

The picture here shows my current output. 这里的图片显示了我当前的输出。



Here is my code... 这是我的代码...

<%@ Page Title="Display Staff Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="DisplayStaff.aspx.cs" Inherits="ASCBioData.About" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h2>
        Display Staff Biography
    </h2>
    <p>
        Staff:
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" 
            DataSourceID="ObjectDataSource1" DataTextField="Name" DataValueField="ID">
        </asp:DropDownList>
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
            InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" 
            SelectMethod="GetData" 
            TypeName="ASCBioData.Data.StaffDataTableAdapters.ASCBioDataTableAdapter">
            <InsertParameters>
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="Education" Type="String" />
                <asp:Parameter Name="BIO" Type="String" />
                <asp:Parameter Name="Highlights" Type="String" />
            </InsertParameters>
        </asp:ObjectDataSource>
        <asp:DetailsView ID="StaffTable" runat="server" AutoGenerateRows="False" 
            CellPadding="10" DataSourceID="ObjectDataSource2" ForeColor="#333333" 
            GridLines="None" Height="50px" Width="916px">
            <AlternatingRowStyle BackColor="White" />
            <CommandRowStyle BackColor="#C5BBAF" Font-Bold="True" HorizontalAlign="Right" />
            <EditRowStyle BackColor="#8E8064" Wrap="True" />
            <FieldHeaderStyle BackColor="#D0D0D0" Font-Bold="True" VerticalAlign="Top" 
                Width="70px" />
            <Fields>
                <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" 
                    ReadOnly="True" SortExpression="ID" Visible="False" />
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                <asp:BoundField DataField="Education" HeaderText="Education" 
                    SortExpression="Education" />
                <asp:BoundField DataField="BIO" HeaderText="BIO" SortExpression="BIO" />
                <asp:BoundField DataField="Highlights" HeaderText="Highlights" 
                    SortExpression="Highlights" />
                <asp:CommandField ShowEditButton="True" />
            </Fields>
            <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <InsertRowStyle Height="300px" />
            <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#E3EAEB" />
        </asp:DetailsView>
        <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" 
            InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" 
            SelectMethod="GetDataByID" 
            TypeName="ASCBioData.Data.StaffDataTableAdapters.ASCBioDataTableAdapter" 
            UpdateMethod="UpdateStaffData">
            <InsertParameters>
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="Education" Type="String" />
                <asp:Parameter Name="BIO" Type="String" />
                <asp:Parameter Name="Highlights" Type="String" />
            </InsertParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="DropDownList1" Name="IsID" 
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="original_ID" Type="Int32" />
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="Education" Type="String" />
                <asp:Parameter Name="BIO" Type="String" />
                <asp:Parameter Name="Highlights" Type="String" />
            </UpdateParameters>
        </asp:ObjectDataSource>
    </p>
</asp:Content>

Please advise and thanks in advance... 请提前告知并感谢...

you can use <asp:TemplateField /> then inside you can use <asp:TextBox /> and set TextMode="MultiLine" . 您可以使用<asp:TemplateField />然后在内部使用<asp:TextBox />并设置TextMode="MultiLine" So something like 所以像

<asp:TemplateField>
<ItemTemplate>
<%# Eval("Highlights") %>
</ItemTemplate>
<EditItemTemplate>
    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("Highlights") %>'
        TextMode="MultiLine"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>

This is on top of my head so do test the syntax.. but it should give you what you're looking for. 这是我的首要任务,因此请测试语法..但是它应该可以为您提供所需的内容。

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

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