|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
感觉很多控件都必须自己去写代码;用了WebMatrix感觉也不是很好,毕竟没有很强的WYSIWYG效果。现在就不知道如何是好了。aspx页面:
复制代码代码以下:
<asp:DetailsViewID="DetailsView1"runat="server"AutoGenerateRows="False"Height="50px"
Width="500px"OnModeChanging="DetailsView1_ModeChanging"OnItemDeleting="DetailsView1_ItemDeleting"
OnItemUpdating="DetailsView1_ItemUpdating"OnItemInserting="DetailsView1_ItemInserting">
<Fields>
<asp:TemplateFieldHeaderText="ID">
<ItemTemplate>
<%#Eval("Id")%>
</ItemTemplate>
<InsertItemTemplate>
<asp:TextBoxID="txtInsertId"Text="InsertId"runat="server"/>
</InsertItemTemplate>
<EditItemTemplate>
<%#Eval("Id")%>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateFieldHeaderText="Title">
<ItemTemplate>
<%#Eval("Title")%>
</ItemTemplate>
<InsertItemTemplate>
<asp:TextBoxID="txtInsertTitle"Text="InsertTitle"runat="server"/>
</InsertItemTemplate>
<EditItemTemplate>
<asp:TextBoxID="txtEditTitle"Text=<%#Eval("Title")%>runat="server"/>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateFieldHeaderText="Context">
<ItemTemplate>
<%#Eval("LogContext")%>
</ItemTemplate>
<InsertItemTemplate>
<asp:TextBoxID="txtInsertLogContext"Text="InsertLogContext"runat="server"/>
</InsertItemTemplate>
<EditItemTemplate>
<asp:TextBoxID="txtEditLogContext"Text=<%#Eval("LogContext")%>runat="server"/>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateFieldHeaderText="操纵">
<ItemTemplate>
<asp:ButtonID="btnEdit"runat="server"CausesValidation="False"
CommandName="Edit"Text="编纂"/>
<asp:ButtonID="btnNew"runat="server"CausesValidation="False"
CommandName="New"Text="新建"/>
<asp:ButtonID="btnDelete"runat="server"CausesValidation="False"
CommandName="Delete"Text="删除"OnClientClick="returnconfirm(断定要更新该先生信息吗?);"/>
</ItemTemplate>
<InsertItemTemplate>
<asp:ButtonID="btnInsert"runat="server"CausesValidation="True"
CommandName="Insert"Text="拔出"/>
<asp:ButtonID="btnCancel"runat="server"CausesValidation="False"
CommandName="Cancel"Text="作废"/>
</InsertItemTemplate>
<EditItemTemplate>
<asp:ButtonID="btnUpdate"runat="server"CausesValidation="True"
CommandName="Update"Text="更新"OnClientClick="returnconfirm(断定要更新该先生信息吗?);"/>
<asp:ButtonID="btnCancel2"runat="server"CausesValidation="False"
CommandName="Cancel"Text="作废"/>
</EditItemTemplate>
</asp:TemplateField>
</Fields>
</asp:DetailsView>
CS文件:
复制代码代码以下:
usingSystem;
usingSystem.Data;
usingSystem.Configuration;
usingSystem.Web;
usingSystem.Web.Security;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Web.UI.HtmlControls;
usingSystem.Collections.Generic;
publicpartialclass_Default:System.Web.UI.Page
{
protectedvoidPage_Load(objectsender,EventArgse)
{
if(!IsPostBack)
{
DataToBing();
}
}
privatevoidDataToBing()
{
this.DetailsView1.DataSource=DataGridSource();
this.DetailsView1.DataBind();
}
privateList<Log>DataGridSource()
{
List<Log>logs=newList<Log>();
for(inti=1;i<11;i++)
{
Loglog=newLog();
log.Id=i;
log.Title="题目"+i;
log.LogContext="内容"+i;
logs.Add(log);
}
returnlogs;
}
publicclassLog
{
privateintid;
publicintId
{
get{returnid;}
set{id=value;}
}
privatestringtitle;
publicstringTitle
{
get{returntitle;}
set{title=value;}
}
privatestringlogContext;
publicstringLogContext
{
get{returnlogContext;}
set{logContext=value;}
}
}
protectedvoidDetailsView1_ModeChanging(objectsender,DetailsViewModeEventArgse)
{
this.DetailsView1.ChangeMode(e.NewMode);
DataToBing();
}
protectedvoidDetailsView1_ItemDeleting(objectsender,DetailsViewDeleteEventArgse)
{
Response.Write("删除操纵");
}
protectedvoidDetailsView1_ItemUpdating(objectsender,DetailsViewUpdateEventArgse)
{
TextBoxtbTitle=(TextBox)this.DetailsView1.FindControl("txtEditTitle");
TextBoxtbLogContext=(TextBox)this.DetailsView1.FindControl("txtEditTitle");
Response.Write("更新操纵:Title:"+tbTitle.Text+":LogContext:"+tbLogContext.Text);
}
protectedvoidDetailsView1_ItemInserting(objectsender,DetailsViewInsertEventArgse)
{
Response.Write("拔出操纵:");
}
}
一个很大的类库。应用程序之所以难以跨平台,在于直接调用了特定平台的接口,而一个巨大的类库,就能极大地减少应用程序对平台的依赖。 |
|