| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 895 人关注过本帖
标题:detailsview的模式转换
只看楼主 加入收藏
CodeBeginner
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2008-8-12
收藏
 问题点数:0 回复次数:4 
detailsview的模式转换
预实现功能:
 按下edit按钮,edit按钮消失,update按钮出现,detailsview转为编辑模式,DVProfile为detailsview控件名

protected void btnEdit_Click(object sender, EventArgs e)
  {   
    Button btnEdit = (Button)DVProfile.FindControl("btnEdit");
    btnEdit.Visible = false;
    Button btnUpdate = (Button)DVProfile.FindControl("btnUpdate");
    btnUpdate.Visible = true;
    DVProfile.ChangeMode(DetailsViewMode.Edit);
  }

为何detailsview没有转为编辑模式,需要再按下update按钮才转为编辑模式?
搜索更多相关主题的帖子: detailsview 
2008-08-12 08:23
CodeBeginner
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2008-8-12
收藏
得分:0 
有人帮我看看吗?
2008-08-12 19:05
leavestars
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2008-8-11
收藏
得分:0 
先判断
if()
{
Button btnUpdate = (Button)DVProfile.FindControl("btnUpdate");
    btnUpdate.Visible = true;

}
2008-08-13 19:22
CodeBeginner
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2008-8-12
收藏
得分:0 
UserProfile.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="UserProfile.ascx.cs" Inherits="UserControls_UserProfile" %>
<asp:DetailsView ID="DVProfile" runat="server" Height="50px" Width="213px" AutoGenerateRows="False">
  <HeaderTemplate>
    <asp:Label ID="LabelTitle" runat="server" Text="My Profile"></asp:Label>
  </HeaderTemplate>
  <Fields>
    <asp:TemplateField HeaderText="Email:" SortExpression="f_email">
      <EditItemTemplate>
        <asp:TextBox ID="Email" runat="server" Text='<%# Bind("f_email") %>' ValidationGroup="ProfileGroup"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RFV_mail" runat="server" ControlToValidate="Email"
          Display="Dynamic" ErrorMessage="Email requires" SetFocusOnError="True" ValidationGroup="ProfileGroup"></asp:RequiredFieldValidator>
        <asp:RegularExpressionValidator ID="REV_email" runat="server" ControlToValidate="Email"
          Display="Dynamic" ErrorMessage="Email format illegal" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
          ValidationGroup="ProfileGroup" SetFocusOnError="True"></asp:RegularExpressionValidator>
      </EditItemTemplate>
      
      <ItemTemplate>
        <asp:Label ID="Label1" runat="server" Text='<%# Bind("f_email") %>'></asp:Label>
      </ItemTemplate>
    </asp:TemplateField>
   
    <asp:TemplateField HeaderText="Security question:" SortExpression="f_question">
      <EditItemTemplate>
        &nbsp;
        <asp:TextBox ID="question" runat="server" Text='<%# Bind("f_question") %>' MaxLength="100"></asp:TextBox>
        <br />
        <asp:RequiredFieldValidator ID="RFV_question" runat="server" ControlToValidate="question"
          Display="Dynamic" ErrorMessage="question requires" SetFocusOnError="True"></asp:RequiredFieldValidator>
        <asp:RegularExpressionValidator ID="REV_question" runat="server" ErrorMessage="question format illegal" SetFocusOnError="True"
          ValidationGroup="ProfileGroup" ControlToValidate="question" Display="Dynamic" ValidationExpression="^[0-9a-zA-Z]{6,50}$"></asp:RegularExpressionValidator>
      </EditItemTemplate>
     
      <ItemTemplate>
        <asp:Label ID="Label2" runat="server" Text='<%# Bind("f_question") %>'></asp:Label>
      </ItemTemplate>
    </asp:TemplateField>
   
    <asp:TemplateField HeaderText="Your answer:" SortExpression="f_answer">
      <EditItemTemplate>
        <asp:TextBox ID="Answer" runat="server" Text='<%# Bind("f_answer") %>' MaxLength="200" ValidationGroup="ProfileGroup"></asp:TextBox>
        <br />
        <asp:RequiredFieldValidator ID="RFV_answer" runat="server" ControlToValidate="Answer"
          Display="Dynamic" ErrorMessage="answer requires" SetFocusOnError="True" ValidationGroup="ProfileGroup"></asp:RequiredFieldValidator>
        <asp:RegularExpressionValidator ID="REV_answer" runat="server" ControlToValidate="Answer"
          Display="Dynamic" ErrorMessage="answer format illegal" SetFocusOnError="True" ValidationExpression="^[0-9a-zA-Z]{6,50}$"
          ValidationGroup="ProfileGroup"></asp:RegularExpressionValidator>
      </EditItemTemplate>
      
      <ItemTemplate>
        <asp:Label ID="Label3" runat="server" Text='<%# Bind("f_answer") %>'></asp:Label>
      </ItemTemplate>
    </asp:TemplateField>
   
    <asp:TemplateField HeaderText="Address:" SortExpression="f_address">
      <EditItemTemplate>
        <asp:TextBox ID="Address" runat="server" Text='<%# Bind("f_address") %>'></asp:TextBox>
      </EditItemTemplate>
      
      <ItemTemplate>
        <asp:Label ID="Label4" runat="server" Text='<%# Bind("f_address") %>'></asp:Label>
      </ItemTemplate>
    </asp:TemplateField>
   
    <asp:TemplateField HeaderText="ZipCode:" SortExpression="f_zipcode">
      <EditItemTemplate>
        <asp:TextBox ID="Zipcode" runat="server" Text='<%# Bind("f_zipcode") %>'></asp:TextBox>
      </EditItemTemplate>
     
      <ItemTemplate>
        <asp:Label ID="Label5" runat="server" Text='<%# Bind("f_zipcode") %>'></asp:Label>
      </ItemTemplate>
    </asp:TemplateField>
   
    <asp:TemplateField HeaderText="Phone:" SortExpression="f_phone">
      <EditItemTemplate>
        <asp:TextBox ID="Phone" runat="server" Text='<%# Bind("f_phone") %>'></asp:TextBox>
      </EditItemTemplate>
      
      <ItemTemplate>
        <asp:Label ID="Label6" runat="server" Text='<%# Bind("f_phone") %>'></asp:Label>
      </ItemTemplate>
    </asp:TemplateField>
  </Fields>
  <FooterTemplate>
    <asp:Button ID="btnEdit" runat="server" Text="Edit" OnClick="btnEdit_Click" />
    <asp:Button ID="btnUpdate" runat="server" Text="Update" Visible="False" OnClick="btnUpdate_Click" />
  </FooterTemplate>
</asp:DetailsView>

我想实现的是edit按钮隐藏,update按钮可视,detailsview控件转为编辑模式都在点击edit按钮后完成.
2008-08-14 21:15
CodeBeginner
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2008-8-12
收藏
得分:0 
期待回复
2008-08-17 11:41
快速回复:detailsview的模式转换
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.044280 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved