【问题标题】:Extending the editable box to the end of the detailsview table, using ASP.net使用 ASP.net 将可编辑框扩展到 detailsview 表的末尾
【发布时间】:2015-04-27 18:05:34
【问题描述】:



我目前的任务是做一个带有 Web 界面的 SQL 数据库。我正在使用 Microsoft Visual Web Developer 2010 Express 来开发原型。

我的问题是,使用detailsview编辑用户信息,如何让可编辑的文本框延伸到表格的末尾?如果可能,文本框可以向下延伸,并包裹多余的文本。

这里的picture 显示了我当前的输出。



这是我的代码...

<%@ 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>

请提前告知和感谢...

【问题讨论】:

    标签: asp.net


    【解决方案1】:

    你可以使用&lt;asp:TemplateField /&gt;然后在里面你可以使用&lt;asp:TextBox /&gt;并设置TextMode="MultiLine"。所以像

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

    这是我的头上,所以请测试语法..但它应该给你你正在寻找的东西。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-13
      • 2012-05-03
      相关资源
      最近更新 更多