FormView的EditItemTemplate模板中有3个TextBox,并且已经绑定到相对应的字段,为什么在插入时,我在TextBox输入值后,返回ItemTemplate时却显示为空呢?
解决方案 »
- 请教ADO.NET Entity Framework 和 Exception
- comboimg 用过的进,有个问题请教下!
- FlashPrinter不起作用无法实现转化
- 关于在ASP.NET弹窗口除了response.write("<script>alert('alert')</script>")和Page.ClientScri
- 一个弹出式窗口中二级联动的问题
- 关于 Cookie 的装箱和拆箱
- 寻求基于.Net的bug软件 最好是asp.net(c#)!拒绝灌水!顶之类
- 大家来讨论一下,为什么执行完一段javascript脚本后不执行后台的代码了?
- 如何将textbox的多行数据批量添加到数据库中?
- 高手帮忙看看,当 AllowPaging 设置为真并且选定的数据源不实现 ICollection 时,AllowCustomPaging 必须为真。。这个是什么意思?
- asp 语言简单插入
- sql2005使用windows登入连接字符串怎么写
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head runat="server">
<title>FormView Example</title>
</head>
<body>
<form id="form1" runat="server"> <h3>FormView Example</h3> <asp:formview id="EmployeeFormView"
datasourceid="EmployeeSource"
allowpaging="true"
datakeynames="EmployeeID"
emptydatatext="No employees found."
runat="server"> <rowstyle backcolor="LightGreen"
wrap="false"/>
<editrowstyle backcolor="LightBlue"
wrap="false"/> <itemtemplate>
<table>
<tr>
<td rowspan="4">
<asp:image id="EmployeeImage"
imageurl='<%# Eval("PhotoPath") %>'
alternatetext='<%# Eval("LastName") %>'
runat="server"/>
</td>
<td colspan="2">
</td>
</tr>
<tr>
<td>
<b>Name:</b>
</td>
<td>
<%# Eval("FirstName") %> <%# Eval("LastName") %>
</td>
</tr>
<tr>
<td>
<b>Title:</b>
</td>
<td>
<%# Eval("Title") %>
</td>
</tr>
<tr>
<td colspan="2">
<asp:linkbutton id="Edit"
text="Edit"
commandname="Edit"
runat="server"/>
</td>
</tr>
</table>
</itemtemplate>
<edititemtemplate>
<table>
<tr>
<td rowspan="4">
<asp:image id="EmployeeEditImage"
imageurl='<%# Eval("PhotoPath") %>'
alternatetext='<%# Eval("LastName") %>'
runat="server"/>
</td>
<td colspan="2">
</td>
</tr>
<tr>
<td>
<b>Name:</b>
</td>
<td>
<asp:textbox id="FirstNameUpdateTextBox"
text='<%# Bind("FirstName") %>'
runat="server"/>
<asp:textbox id="LastNameUpdateTextBox"
text='<%# Bind("LastName") %>'
runat="server"/>
</td>
</tr>
<tr>
<td>
<b>Title:</b>
</td>
<td>
<asp:textbox id="TitleUpdateTextBox"
text='<%# Bind("Title") %>'
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:linkbutton id="UpdateButton"
text="Update"
commandname="Update"
runat="server"/>
<asp:linkbutton id="CancelButton"
text="Cancel"
commandname="Cancel"
runat="server"/>
</td>
</tr>
</table>
</edititemtemplate> </asp:formview> <!-- This example uses Microsoft SQL Server and connects -->
<!-- to the Northwind sample database. Use an ASP.NET -->
<!-- expression to retrieve the connection string value -->
<!-- from the Web.config file. -->
<asp:sqldatasource id="EmployeeSource"
selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [PhotoPath] From [Employees]"
updatecommand="Update [Employees] Set [LastName]=@LastName, [FirstName]=@FirstName, [Title]=@Title Where [EmployeeID]=@EmployeeID"
connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
runat="server"/> </form>
</body>
</html>
<asp:FormView ID="Form_OpRsk_TB_EventDetail" runat="server" DataKeyNames="Id" DataSourceID="UserAddEventDetail" >
<EditItemTemplate>
<table>
<tr>
<td class="TitleCell">
事件后续进展
</td>
<td class="InputCell" colspan="3">
<asp:TextBox ID="EventDescriptionTextBox" runat="server" Text='<%# Bind("EventDescription") %>'
Columns="60" MaxLength="300" TextMode="MultiLine">
</asp:TextBox></td>
</tr>
<tr>
<td class="TitleCell">
采取相关措施
</td>
<td class="InputCell" colspan="3">
<asp:TextBox ID="EventActionTextBox" runat="server" Text='<%# Bind("EventAction") %>'
Columns="60" MaxLength="300" TextMode="MultiLine">
</asp:TextBox>
</td>
</tr>
<tr>
<td class="TitleCell">
实际损失金额更新
</td>
<td class="InputCell" colspan="3">
<asp:TextBox ID="AmountRealChangeTextBox" runat="server" Text='<%# Bind("AmountRealChange","{0:N2}") %>'
ToolTip="必须输入角分"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="4">
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
Text="更新事件追踪">
</asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="取消追踪更新">
</asp:LinkButton>
</td>
</tr>
</table>
</EditItemTemplate>
<InsertItemTemplate>
<table>
<tr>
<td class="TitleCell">
事件后续进展
</td>
<td class="InputCell" colspan="3">
<asp:TextBox ID="EventDescriptionTextBox" runat="server" Text='<%# Bind("EventDescription") %>'
Columns="60" MaxLength="300" TextMode="MultiLine">
</asp:TextBox></td>
</tr>
<tr>
<td class="TitleCell">
采取相关措施
</td>
<td class="InputCell" colspan="3">
<asp:TextBox ID="EventActionTextBox" runat="server" Text='<%# Bind("EventAction") %>'
Columns="60" MaxLength="300" TextMode="MultiLine">
</asp:TextBox>
</td>
</tr>
<tr>
<td class="TitleCell">
实际损失金额更新
</td>
<td class="InputCell" colspan="3">
<asp:TextBox ID="AmountRealChangeTextBox" runat="server" Text='<%# Bind("AmountRealChange","{0:N2}") %>'
ToolTip="必须输入角分">
</asp:TextBox>
</td>
</tr>
<tr>
<td colspan="4">
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
Text="保存事件追踪" Width="100px"></asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="取消事件追踪" Width="100px"></asp:LinkButton>
</td>
</tr>
</table>
</InsertItemTemplate>
<ItemTemplate>
<table>
<tr>
<td class="TitleCell">
事件后续进展
</td>
<td class="InputCell" colspan="3">
<asp:Label ID="EventDescriptionLabel" runat="server" Text='<%# Bind("EventDescription") %>' Width="127px"></asp:Label>
</td>
</tr>
<tr>
<td class="TitleCell">
采取相关措施
</td>
<td class="InputCell" colspan="3">
<asp:Label ID="EventActionLabel" runat="server" Text='<%# Bind("EventAction") %>' Width="120px"></asp:Label>
</td>
</tr>
<tr>
<td class="TitleCell">
实际损失金额更新
</td>
<td class="InputCell" colspan="3">
<asp:Label ID="AmountRealChangeLabel" runat="server" Text='<%# Bind("AmountRealChange","{0:C2}") %>'>
</asp:Label>
</td>
</tr>
<tr>
<td class="TitleCell" colspan="4">
<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
Text="登记事件追踪" Width="100px" OnClick="NewButton_Click"></asp:LinkButton>
<asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
Text="编辑事件追踪" Width="100px"></asp:LinkButton>
<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete"
Text="提交事件追踪" Width="100px" OnClientClick="javascript:return(confirm('提交后将不能编辑。确认提交?'));">
</asp:LinkButton>
</td>
</tr>
</table>
</ItemTemplate>
<EmptyDataTemplate>
<h3>
没有未提交的事件追踪</h3>
<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
Text="新建事件追踪" Width="100px">
</asp:LinkButton>
</EmptyDataTemplate>
</asp:FormView>
<br />
<asp:SqlDataSource ID="Auth_TB_Operator" runat="server" ConnectionString="<%$ ConnectionStrings:CcisConnectionString %>"
DataSourceMode="DataReader" ProviderName="<%$ ConnectionStrings:CcisConnectionString.ProviderName %>"
SelectCommand="SELECT NULL AS [Id], NULL AS [Name], NULL AS [Caption] UNION SELECT [Id], [Name], [Caption] +'('+ [Name] +')' AS [Caption] FROM [Auth_TB_Operator]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="Department" runat="server" ConnectionString="<%$ ConnectionStrings:CcisConnectionString %>"
DataSourceMode="DataReader" ProviderName="<%$ ConnectionStrings:CcisConnectionString.ProviderName %>"
SelectCommand="SELECT Id, Caption, ManagerId FROM dbo.OpRsk_TB_Department"></asp:SqlDataSource>
<asp:SqlDataSource ID="EventTypes" runat="server" ConnectionString="<%$ ConnectionStrings:CcisConnectionString %>"
DataSourceMode="DataReader" ProviderName="<%$ ConnectionStrings:CcisConnectionString.ProviderName %>"
SelectCommand="SELECT [Code], [Code]+':'+[Caption] AS Caption FROM [OpRsk_TB_EventType]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="Dic_OperationRiskLevel" runat="server" ConnectionString="<%$ ConnectionStrings:CcisConnectionString %>"
DataSourceMode="DataReader" ProviderName="<%$ ConnectionStrings:CcisConnectionString.ProviderName %>"
SelectCommand="SELECT [KeyId], [Caption] FROM [Dic_VR_Type_Value] WHERE ([TypeName] = 'OperationRiskLevel')">
</asp:SqlDataSource>
<asp:SqlDataSource ID="UserAddEventDetail" runat="server" ConnectionString="<%$ ConnectionStrings:CcisConnectionString %>"
SelectCommand="SELECT [Id], [EventId], [EventDescription], [EventAction], [Recorder], [RecordDate], [Reviewer], [ReviewDate], [AmountRealChange] FROM [OpRsk_TB_EventDetail] WHERE [Recorder]=@UserId AND [EventId]=@EventId And [Reviewer] IS NULL"
DeleteCommand="UPDATE dbo.OpRsk_TB_EventDetail SET Reviewer=@Reviewer WHERE Id=@Id"
InsertCommand="INSERT INTO dbo.OpRsk_TB_EventDetail(EventId, EventDescription, EventAction, Recorder, AmountRealChange) VALUES (@EventId,@EventDescription,@EventAction,@Recorder,CASE WHEN RTRIM(@AmountRealChange)='' THEN NULL ELSE @AmountRealChange END)"
UpdateCommand="UPDATE dbo.OpRsk_TB_EventDetail SET EventDescription =@EventDescription, EventAction =@EventAction, AmountRealChange = CASE WHEN RTRIM(@AmountRealChange)='' THEN NULL ELSE @AmountRealChange END WHERE Id=@Id">
<DeleteParameters>
<asp:ControlParameter ControlID="Form_OpRsk_TB_EventDetail" Name="Id" PropertyName="SelectedValue" />
</DeleteParameters>
<UpdateParameters>
<asp:ControlParameter ControlID="Form_OpRsk_TB_EventDetail" Name="Id" PropertyName="SelectedValue" />
</UpdateParameters>
<SelectParameters>
<asp:ControlParameter ControlID="CurrentUserId" Name="UserId" PropertyName="Text" />
<asp:ControlParameter ControlID="FormViewTrackInfo" Name="EventId" PropertyName="SelectedValue" />
</SelectParameters>
<InsertParameters>
<asp:ControlParameter ControlID="FormViewTrackInfo" Name="EventId" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="CurrentUserId" Name="Recorder" PropertyName="Text" />
</InsertParameters>
</asp:SqlDataSource>
<asp:Label ID="CurrentUserId" runat="server"></asp:Label>