KissU下的SmartFormView

KissU下的SmartFormView

Aspx页面代码:

<asp:Content ContentPlaceHolderID="head" ID="idFormTitle" runat="server">

<title><%=Request["title"]%></title>

</asp:Content>

<asp:Content ContentPlaceHolderID="Content" ID="idFormMain" runat="server">

<web:SmartFormView ID="SmartFormView1" runat="server" DataKeyNames="Id" DataSourceID="SmartDataSource1"

Width="100%">

<InsertItemTemplate></InsertItemTemplate>

<EditItemTemplate></EditItemTemplate>

<ItemTemplate>

<asp:TextBox ID='Id' runat='server' Text='<%# Bind("Id") %>' Width='90%'

Visible="false"></asp:TextBox>

<div><table cellpadding='2' cellspacing='1' width='100%' class="formitem">

<caption><%=Request["title"]%></caption><tr>

<th>名称:<font color='red'>*<ont></th><td><asp:TextBox ID='TextBox1' runat='server' Text='<%# Bind("Name") %>' Width='90%' MaxLength="30"

validator="required,length[1,30]"></asp:TextBox></td></tr><tr>

<th>编码:<font color='red'>*</font></th>

<td><asp:TextBox ID='Code' runat='server' Text='<%# Bind("Code") %>' Width='90%' MaxLength="20"

validator="required,length[1,20]"></asp:TextBox></td>

</tr>

<tr><th>描述:</th>

<td><asp:TextBox TextMode="MultiLine" Rows="5" Columns="50" ID="Description" runat="server" Text='<%# Eval("Description") %>' Width='90%'></asp:TextBox></td></tr></table></div>

</ItemTemplate>

</web:SmartFormView>

<web:SmartSqlDataSource ID="SmartDataSource1" runat="server" SelectCommand="dataDictionary.select"

SelectCommandAutoPageWrap="false" InsertCommand="dataDictionary.insert" UpdateCommand="dataDictionary.update">

</web:SmartSqlDataSource>

<!-- 页脚区域 -->

<div class="footer">

<asp:Button runat="server" Text="确定"

OnClientClick="return validateForm();" onclick="Save"/>

<asp:Button ID="CloseButton2" runat="server" Text="关闭" OnClientClick="return closeForm();" />

</div>

</asp:Content>

CS后台代码:

public partial class DataDictionaryEdit : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

}

protected void Save(object sender, EventArgs e)

{

string id = this.SmartFormView1["Id"] as string;

string code = this.SmartFormView1["Code"] as string;

if (this.DataDictionaryService.IsDictionaryCodeExist(code, id))

{

ScriptHelper.Alert(this, "编码必须保持唯一,请重新填写");

}

else

{

this.SmartFormView1.SaveOrUpdate(); //这里调用SmartFormView的SaveOrUpdate()

ScriptHelper.CloseDialog(this, "true");

}

}

private DataDictionaryService _dataDictionaryService;

private DataDictionaryService DataDictionaryService

{

get

{

return _dataDictionaryService ??

(_dataDictionaryService = ObjectHelper.GetObject<DataDictionaryService>());

}

}

}

posted @ 2013-12-08 23:05  weifb  阅读(129)  评论(0)    收藏  举报