我有一个现有的详细信息视图表单,工作正常。我添加了7个新字段,数据绑定文本框。但是,当页面加载时,没有错误,但禁用了详细信息视图。无法找到原因的解决方案。
<asp:DetailsView ID="DetailsView2" runat="server" `AutoGenerateRows="False" DataKeyNames="intaccno,intsequenceno"`
DataSourceID="ObjectDataSource3" Height="4px" Width="349px"
DefaultMode="Edit" onitemupdated="DetailsView2_ItemUpdated"
CellPadding="4" EnableModelValidation="True" ForeColor="#333333"
GridLines="None" AllowPaging="True">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
<EditRowStyle BackColor="#999999" />
<EmptyDataTemplate>
There is not data to display
</EmptyDataTemplate>
<FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
<Fields>
<asp:TemplateField HeaderText="Status" SortExpression="txt1status">
<EditItemTemplate>
<asp:TextBox ID="txtStatus" runat="server" Enabled="False"
Text='<%# Bind("txt1status") %>'></asp:TextBox>
<asp:CheckBox ID="chkCancelReview" runat="server" AutoPostBack="True"
oncheckedchanged="chkCancelReview_CheckedChanged"
Text="Cancel Review (only approvers can cancel)" Visible="False" />
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" Enabled="False"
Text='<%# Bind("txt1status") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("txt1status") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="BMS Comments">
<EditItemTemplate>
<asp:TextBox ID="TextBox5" runat="server" Height="61px" ReadOnly="True"
Text='<%# Bind("systemcomments") %>' TextMode="MultiLine" Width="786px"></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("systemcomments") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("systemcomments") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CRR" SortExpression="CreditRiskRating">
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("CreditRiskRating") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("CreditRiskRating") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("CreditRiskRating") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CQR" SortExpression="CreditQualityRating">
<EditItemTemplate>
<asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("CreditQualityRating") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox14" runat="server" Text='<%# Bind("CreditQualityRating") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label14" runat="server" Text='<%# Bind("CreditQualityRating") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SCLT" SortExpression="SugarcaneLoanTemplate">
<EditItemTemplate>
<asp:TextBox ID="TextBox11" runat="server" Text='<%# Bind("SugarcaneLoanTemplate") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox15" runat="server" Text='<%# Bind("SugarcaneLoanTemplate") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label15" runat="server" Text='<%# Bind("SugarcaneLoanTemplate") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Valuation" SortExpression="Valuation">
<EditItemTemplate>
<asp:TextBox ID="TextBox12" runat="server" Text='<%# Bind("Valuation") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox16" runat="server" Text='<%# Bind("Valuation") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label16" runat="server" Text='<%# Bind("Valuation") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Financials" SortExpression="Financials">
<EditItemTemplate>
<asp:TextBox ID="TextBox13" runat="server" Text='<%# Bind("Financials") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox17" runat="server" Text='<%# Bind("Financials") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label17" runat="server" Text='<%# Bind("Financials") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="BSCP" SortExpression="BusinessSuccessionContinuityPlan">
<EditItemTemplate>
<asp:TextBox ID="TextBox14" runat="server" Text='<%# Bind("BusinessSuccessionContinuityPlan") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox18" runat="server" Text='<%# Bind("BusinessSuccessionContinuityPlan") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label18" runat="server" Text='<%# Bind("BusinessSuccessionContinuityPlan") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="IOA" SortExpression="InsuranceofAssets">
<EditItemTemplate>
<asp:TextBox ID="TextBox15" runat="server" Text='<%# Bind("InsuranceofAssets") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox19" runat="server" Text='<%# Bind("InsuranceofAssets") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label19" runat="server" Text='<%# Bind("InsuranceofAssets") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SecurityComments" SortExpression="SecurityComments">
<EditItemTemplate>
<asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("SecurityComments") %>' Height="67px" TextMode="MultiLine" Width="750px"></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("SecurityComments") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label7" runat="server" Text='<%# Bind("SecurityComments") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ServiceabilityComments" SortExpression="ServiceabilityComments">
<EditItemTemplate>
<asp:TextBox ID="TextBox8" runat="server"
Text='<%# Bind("ServiceabilityComments") %>' Height="47px" TextMode="MultiLine"
Width="750px" CausesValidation="True"></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox8" runat="server" Text='<%# Bind("ServiceabilityComments") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label8" runat="server" Text='<%# Bind("ServiceabilityComments") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Comments" SortExpression="Comments">
<EditItemTemplate>
<asp:TextBox ID="TextBox9" runat="server" Text='<%# Bind("Comments") %>' Height="179px" Width="756px" TextMode="MultiLine"></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox9" runat="server" Text='<%# Bind("Comments") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label9" runat="server" Text='<%# Bind("Comments") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Recommendation" SortExpression="Recommendation">
<EditItemTemplate>
<asp:TextBox ID="TextBox10" runat="server" Text='<%# Bind("Recommendation") %>' Height="196px" TextMode="MultiLine" Width="746px"></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox10" runat="server" Text='<%# Bind("Recommendation") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label10" runat="server" Text='<%# Bind("Recommendation") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Approver's Comments"
SortExpression="txt90report">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("txt90report") %>'
TextMode="MultiLine" Width="797px"></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("txt90report") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("txt90report") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SBMComments">
<EditItemTemplate>
<asp:TextBox ID="txtSBMComments" runat="server" Height="75px"
Text='<%# Bind("SBMComments") %>' TextMode="MultiLine" Width="589px"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SBMOfficer">
<EditItemTemplate>
<asp:TextBox ID="txtSBMOfficer" runat="server" Enabled="False"
Text='<%# Eval("SBMOfficer") %>' Width="207px"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Send For Approval"
SortExpression="SentForApproval">
<EditItemTemplate>
<asp:CheckBox ID="chkSend" runat="server" Checked='<%# Bind("SentForApproval") %>'
Style="position: relative" />
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox11" runat="server" Text='<%# Bind`("SentForApproval") %>'></asp:TextBox>`
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label11" runat="server" Text='<%# Bind
("SentForApproval") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Review Officer" `SortExpression="reviewOfficer">`
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind`("reviewOfficer") %>'`
Enabled="False"></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox12" runat="server" Text='<%# Bind`("reviewOfficer") %>'></asp:TextBox>`
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label12" runat="server" Text='<%# Bind
("reviewOfficer") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Approver" SortExpression="Approver">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server"
SelectedValue='<%# Bind("BranchManager") %>'
Style="position: relative"
DataSourceID="ObjectDataSourceUsers"
DataTextField="txt60name" DataValueField="txt60name" `Width="134px"`
AppendDataBoundItems="True">
<asp:ListItem>Rudra Singh</asp:ListItem>
<asp:ListItem></asp:ListItem>
<asp:ListItem>RUDRA SINGH</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox13" runat="server" Text='<%# Bind
("BranchManager") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label13" runat="server" Text='<%# Bind
("BranchManager") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Approve">
<EditItemTemplate>
<asp:CheckBox ID="chkApprove" runat="server" Checked='<%# `Bind("Approved") %>'`
Text="Click here to approve" Visible="False" />
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" />
</Fields>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
</asp:DetailsView>
using System;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.ComponentModel;
using System.Drawing;
using System.Web.SessionState;
using System.Text;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
CheckBox chkApprove = (CheckBox)DetailsView2.FindControl("chkApprove");
CheckBox chkSendForApproval = (CheckBox)DetailsView2.FindControl("chkSend");
TextBox reviewOfficer = (TextBox)DetailsView2.FindControl("textbox3");
TextBox Status = (TextBox)DetailsView2.FindControl("textbox4");
TextBox ManagerComments = (TextBox)DetailsView2.FindControl("textbox2");
TextBox SBMOfficer = (TextBox)DetailsView2.FindControl("txtSBMOfficer");
TextBox SBMComments = (TextBox)DetailsView2.FindControl("txtSBMComments");
CheckBox chkCancelReview = (CheckBox)DetailsView2.FindControl("chkCancelReview");
chkCancelReview.Visible = false;
if (User.IsInRole("ReviewApprover"))
{
chkCancelReview.Visible = true;
if (chkApprove != null)
{
chkApprove.Visible = true;
}
if (chkSendForApproval != null)
{
chkSendForApproval.Visible = false;
}
SBMOfficer.Text = SBMOfficer.Text; //User.Identity.Name.ToString();
SBMComments.Enabled = true;
SBMOfficer.Enabled = true;
}
else if (User.IsInRole("ReviewRequester"))
{
if (chkApprove != null)
{
chkApprove.Visible = false;
}
if (chkSendForApproval != null)
{
chkSendForApproval.Visible = true;
}
ManagerComments.Enabled = false;
SBMComments.Enabled = false;
SBMOfficer.Enabled = false;
reviewOfficer.Text = User.Identity.Name.ToString();
}
else
{
reviewOfficer.Text = User.Identity.Name.ToString();
chkApprove.Visible = false;
chkSendForApproval.Visible = false;
DetailsView2.DefaultMode = DetailsViewMode.ReadOnly;
}
if (Status != null)
{
if (Status.Text != "O")
{
DetailsView2.Enabled = false;
}
}
}
catch (Exception ex)
{
myMessageBox.myMessageBox.Show(ex.Message.ToString().Replace("\r", "").Replace("\n", ""));
}
}
protected void LinkButton3_Click(object sender, EventArgs e)
{
String myurl;
myurl = "Projections.aspx?accno=" + Convert.ToString(Session["Accno"]) + "&seqno=" + Convert.ToString(Session["ReviewSeqNo"]);
Response.Write("<script type='text/javascript'>window.open('" + myurl + "','_blank');</script>");
//Response.Redirect(myurl);
}
protected void LinkButton4_Click(object sender, EventArgs e)
{
String myurl;
// myMessageBox.myMessageBox.Show(ConfigurationSettings.AppSettings["ReportServer"].ToString());
// myurl = "http://" + ConfigurationSettings.AppSettings["ReportServer"].ToString() + "/ReportServer/Pages/ReportViewer.aspx?%2fReview%2fReviewReport&rs:Command=Render&intaccno=" + Convert.ToString(Request.QueryString["accountNo"]) + "&type=D&seqno=" + Convert.ToString(Request.QueryString["seqno"]);
//Added by Cherie 09/09/2009 to point users to review parallel report
myurl = "http://" + ConfigurationManager.AppSettings["ReportServer"].ToString() + "/ReportServer/Pages/ReportViewer.aspx?%2fReview%2fReviewReportForParallel&rs:Command=Render&intaccno=" + Convert.ToString(Request.QueryString["accountNo"]) + "&type=D&seqno=" + Convert.ToString(Request.QueryString["seqno"]);
Response.Write("<script type='text/javascript'>window.open('" + myurl + "','_blank');</script>");
//Response.Redirect(myurl);
}
protected void DetailsView2_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
{
try
{
CheckBox chkSendForApproval = (CheckBox)DetailsView2.FindControl("chkSend");
CheckBox chkApprove = (CheckBox)DetailsView2.FindControl("chkApprove");
if (chkSendForApproval.Checked && !chkApprove.Checked)
{
myMessageBox.myMessageBox.Show("The review is done from your side and has been sent to your manager for approval.");
}
else if (chkSendForApproval.Checked && chkApprove.Checked)
{
myMessageBox.myMessageBox.Show("This review is now complete!");
}
else
{
myMessageBox.myMessageBox.Show("Please ensure that the send for approval check box is checked if you want to send this review to your manager for approval");
}
}
catch (Exception ex)
{
myMessageBox.myMessageBox.Show(ex.Message.ToString().Replace("\r", "").Replace("\n", ""));
}
}
protected void LinkButton5_Click(object sender, EventArgs e)
{
Response.Redirect("AnnualReview.aspx", false);
}
protected void chkCancelReview_CheckedChanged(object sender, EventArgs e)
{
CheckBox chkCancelReview = (CheckBox)DetailsView2.FindControl("chkCancelReview");
TextBox txtStatus = (TextBox)DetailsView2.FindControl("txtStatus");
if (chkCancelReview.Checked)
{
txtStatus.Text = "X";
}
else
{
txtStatus.Text = "O";
}
}
}
答案 0 :(得分:0)
如果7个新字段没有绑定值,但是旧版本有,请确保控制器中的新文件给定值,当您提出问题时,最好显示代码。