如何处理此行编辑错误 [英] How Can I Handle This Row Editing Error

查看:63
本文介绍了如何处理此行编辑错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该怎么做才能处理Row编辑事件。它编辑了我不需要的模板。如何在更新后停止行编辑和显示消息。

重要

1.使用Viewstate获取唯一身份。

2.On编辑链接按钮单击Gridview数据发布文本框中的数据返回

3.更新按钮单击gridview显示编辑。



如何解决问题



公共部分类Listofappointment:System.Web.UI.Page

{

string username;

字符串密码;

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings [NRIHealthPortal] .ConnectionString);

protected void Page_Load(object sender ,EventArgs e)

{

if(Session [UserName]!= null&& Session [Password]!= null)

{

username = Session [UserName]。ToString();

password = Session [Password]。ToString();

bindgrid();

}

lblUserName.Text = username.ToString();

//lblMessage.Text =数据更新成功;

}

protected void btnUpdate_Click(object sender,EventArgs e)

{

try

{

con.Open();

SqlCommand cmd = new SqlCommand(SP_UpdateAppointmentWithDoctor,con);

cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.AddWithValue(@ PatientId,Int32.Parse(ViewState [PatientId]。ToString()));

cmd.Parameters.AddWithValue(@ Patientname,txtPatientName .Text);

cmd.Parameters.AddWithValue(@ AppointmentReason,txtAppointmentReason.Text);

cmd.Parameters.AddWithValue(@ Email,txtEmail.Text );

cmd.Parameters.AddWithValue(@ MobileNo,txtMobileNo.Text);

cmd.Parameters.AddWithVal ue(@ AppointmentDate,DateTime.Parse(txtAppointmentDate.Text));

cmd.ExecuteNonQuery();

con.Close();





bindgrid();

}

catch(例外情况)

{



}



ScriptManager.RegisterStartupScript(this,this.GetType(), md,alert('Successfullyfully');,true);

//Response.Redirect (\"listofappointment.aspx);

}

protected void bindgrid()

{

con.Open();

SqlCommand cmd = new SqlCommand(lastappointment ,con);

cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.AddWithValue(@ Username,username.ToString());

cmd.Parameters.AddWithValue(@ Password,password.ToString());

S qlDataAdapter da = new SqlDataAdapter(cmd);

DataTable dt = new DataTable();

da.Fill(dt);

con。关闭();

grdappointment.DataSource = dt;

grdappointment.DataBind();

}

protected void grdappointment_RowCommand(object sender,GridViewCommandEventArgs e)

{

if(e.CommandName ==Edit)

{



LinkBut​​ton btn =(LinkBut​​ton)e.CommandSource;

ViewState [PatientId] = e.CommandArgument;

GridViewRow grdrow =((GridViewRow)btn.NamingContainer);

Label lblPatientName1 =(Label)grdrow.FindControl(lblgrdPatientName);

Label lblAppointmentReason1 =(Label)grdrow。 FindControl(lblgrdAppointmentReason);

标签lblEmail1 =(标签)grdrow.FindControl(lblgrdEmail);

Label lblMobil eNo1 =(标签)grdrow.FindControl(lblgrdMobileNo);

标签lblAppointmentDate1 =(标签)grdrow.FindControl(lblgrdAppointmentDate);

txtPatientName.Text = lblPatientName1 .Text;

txtAppointmentReason.Text = lblAppointmentReason1.Text;

txtEmail.Text = lblEmail1.Text;

txtMobileNo.Text = lblMobileNo1.Text ;

txtAppointmentDate.Text = lblAppointmentDate1.Text;

btnUpdate.Visible = true;

}

if( e.CommandName ==删除)

{

ViewState [PatientId] = e.CommandArgument;

LinkBut​​ton btn =(LinkBut​​ton )e.CommandSource;

GridViewRow grdrow =((GridViewRow)btn.NamingContainer);

SqlCommand cmd = new SqlCommand(SP_AppointmentDelete,con);

cmd.CommandType = CommandType.StoredProcedu re;

cmd.Parameters.AddWithValue(@ PatientId,Convert.ToInt16(ViewState [PatientId]));

con.Open();

cmd.ExecuteNonQuery();

con.Close();

bindgrid();

}

}

protected void grdappointment_RowEditing(object sender,GridViewEditEventArgs e)

{

//grdappointment.EditIndex = e.NewEditIndex ;

// bindgrid();

//Response.Redirect(\"Listofappointment.aspx);

}

protected void grdappointment_RowDeleting(object sender,GridViewDeleteEventArgs e)

{



}

}





HTML COde



What should I do to Handle Row editing event. It edits the template which i dont required . How can i Stop the row editing and show message after Updation.
Important
1. Use Viewstate for Unique Identity.
2.On edit linkbutton click the Gridview Data post the Data in Textboxes Back
3. On update button Click gridview shows edit .

How Can i resolve the Problem

public partial class Listofappointment : System.Web.UI.Page
{
string username;
string password;
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["NRIHealthPortal"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
if (Session["UserName"] != null && Session["Password"] != null)
{
username = Session["UserName"].ToString();
password = Session["Password"].ToString();
bindgrid();
}
lblUserName.Text = username.ToString();
//lblMessage.Text = "Data Updated Succesfully";
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
try
{
con.Open();
SqlCommand cmd = new SqlCommand("SP_UpdateAppointmentWithDoctor", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@PatientId", Int32.Parse(ViewState["PatientId"].ToString()));
cmd.Parameters.AddWithValue("@Patientname", txtPatientName.Text);
cmd.Parameters.AddWithValue("@AppointmentReason", txtAppointmentReason.Text);
cmd.Parameters.AddWithValue("@Email", txtEmail.Text);
cmd.Parameters.AddWithValue("@MobileNo", txtMobileNo.Text);
cmd.Parameters.AddWithValue("@AppointmentDate", DateTime.Parse(txtAppointmentDate.Text));
cmd.ExecuteNonQuery();
con.Close();


bindgrid();
}
catch (Exception ex)
{

}

ScriptManager.RegisterStartupScript(this, this.GetType(), "md", "alert('Updated Successfully');", true);
//Response.Redirect("listofappointment.aspx");
}
protected void bindgrid()
{
con.Open();
SqlCommand cmd = new SqlCommand("lastappointment", con);
cmd.CommandType=CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Username", username.ToString());
cmd.Parameters.AddWithValue("@Password", password.ToString());
SqlDataAdapter da=new SqlDataAdapter(cmd);
DataTable dt =new DataTable();
da.Fill(dt);
con.Close();
grdappointment.DataSource=dt;
grdappointment.DataBind();
}
protected void grdappointment_RowCommand(object sender, GridViewCommandEventArgs e)
{
if(e.CommandName=="Edit")
{

LinkButton btn = (LinkButton)e.CommandSource;
ViewState["PatientId"] = e.CommandArgument;
GridViewRow grdrow = ((GridViewRow)btn.NamingContainer);
Label lblPatientName1 = (Label)grdrow.FindControl("lblgrdPatientName");
Label lblAppointmentReason1 = (Label)grdrow.FindControl("lblgrdAppointmentReason");
Label lblEmail1 = (Label)grdrow.FindControl("lblgrdEmail");
Label lblMobileNo1 = (Label)grdrow.FindControl("lblgrdMobileNo");
Label lblAppointmentDate1 = (Label)grdrow.FindControl("lblgrdAppointmentDate");
txtPatientName.Text = lblPatientName1.Text;
txtAppointmentReason.Text = lblAppointmentReason1.Text;
txtEmail.Text = lblEmail1.Text;
txtMobileNo.Text = lblMobileNo1.Text;
txtAppointmentDate.Text = lblAppointmentDate1.Text;
btnUpdate.Visible = true;
}
if (e.CommandName == "Delete")
{
ViewState["PatientId"] = e.CommandArgument;
LinkButton btn = (LinkButton)e.CommandSource;
GridViewRow grdrow = ((GridViewRow)btn.NamingContainer);
SqlCommand cmd = new SqlCommand("SP_AppointmentDelete", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@PatientId", Convert.ToInt16(ViewState["PatientId"]));
con.Open();
cmd.ExecuteNonQuery();
con.Close();
bindgrid();
}
}
protected void grdappointment_RowEditing(object sender, GridViewEditEventArgs e)
{
//grdappointment.EditIndex = e.NewEditIndex;
//bindgrid();
//Response.Redirect("Listofappointment.aspx");
}
protected void grdappointment_RowDeleting(object sender, GridViewDeleteEventArgs e)
{

}
}


HTML COde





<%----%>

<%----%>

欢迎< asp:标签ID =lblUserNamerunat =serverText => < asp:Label ID = lblPasswordrunat =serverText =>
< asp:Label ID =lblPatientNamerunat =serverText =Patient Name>

< asp:TextBox ID =txtPatientNamerunat =serverMaxLength =24>

< asp:RequiredFieldValidator ID =RequiredFieldValidator1runat =serverControlToValidate =txtPatientName

ErrorMessage =请填写患者姓名SetFocusOnError =TrueValidationGroup =提交>

< asp:FilteredTextBoxExtender ID =FilteredTextBoxExtender2runat =serverTargetControlID =txtPatientNameFilterType =UppercaseLetters,LowercaseLettersFilterMode =InvalidCharsInvalidChars =〜!#$%^& *()_ = - :?{} /, 1234567890>

< asp:Label ID =lblAppointmentReasonrunat =serverText =Appointment Reason>

< asp:TextBox ID =txtAppointmentReasonrunat =serverMaxLength =50>

< asp:FilteredTextBoxExtender ID =FilteredTextBoxExtender3runat =serverTargetControlID =txtAppointmentReasonFilterType =UppercaseLetters,LowercaseLettersFilterMode =InvalidCharsInvalidChars =〜!#$%^& *()_ = - :{}?/。, 1234567890>

< asp:RequiredFieldValidator ID =RequiredFieldValidator2runat =serverControlToValidate =txtAppointmentReason

ErrorMessage =请填写Appointmet ReasonSetFocusOnError = TrueValidationGroup =Submit>

< asp:Label ID =lblAppointmentTyp erunat =serverText =Appointment Type>
< asp:TextBox ID =txtAppointmentTyperunat =serverMaxLength =30>

< asp:RequiredFieldValidator ID =RequiredFieldValidator3 runat =server

ControlToValidate =txtAppointmentType

ErrorMessage =请填写预约类型SetFocusOnError =True

ValidationGroup = 提交>

< asp:标签ID =lblLocationrunat =serverText =Location> < asp:TextBox ID =txtLocationrunat =serverMaxLength =30>

< asp:RequiredFieldValidator ID =RequiredFieldValidator4runat =server

ControlToValidate =txtLocationErrorMessage =请填写位置

SetFocusOnError =TrueValidationGroup =提交>

< asp:Label ID =lblDaterunat =serverText =约会日期>

< asp:TextBox ID =txtAppointmentDaterunat =serverAutoPostBack =true>

< asp:ImageButton ID =imgButtonrunat =serverImageUrl =〜/ images / kkalendari.png

ImageAlign =中间/>

< asp:CalendarExtender ID =CalendarExtender1runat =serverPopupButtonID =imgButton

TargetControlID =txtAppointmentDateFormat =dd / MM / yyyy>



< asp:RequiredFieldValidator ID =RequiredFieldValidator5 runat =serverControlToValidate =txtAppointmentDate

ErrorMessage =请填写预约日期SetFocusOnError =TrueValidationGroup =提交>

< asp:Label ID =lblEmailrunat =serverText =Email>

< asp:TextBox ID =txtEmailrunat =server>

< asp:RequiredFieldValidator ID =RequiredFieldValidator6runat =serverControlToValidate =txtEmail

ErrorMessage =请填写电子邮件IDSetFocusOnError =TrueValidationGroup =提交>

< asp:RegularExpressionValidator ID =RegularExpressionValidator1runat =serverControlToValidate =txtEmail

ErrorMessage =请填写有效的电子邮件SetFocusOnError =TrueValidationExpression =\ w +([ - +。'] \ w +)* @ \ w +([ - 。] \w +)* \.\\\ +([ - 。] \ w +)*

ValidationGroup =提交>

< asp:Label ID =lblMobileNorunat =serverText =Mobile No.>

< ASP:TEXTB ox ID =txtMobileNorunat =serverMaxLength =10>

< asp:FilteredTextBoxExtender ID =FilteredTextBoxExtender1runat =serverTargetControlID =txtMobileNo

FilterType =Numbers>



< asp:RequiredFieldValidator ID =RequiredFieldValidator7runat =serverControlToValidate =txtMobileNo

ErrorMessage =请填写手机号码SetFocusOnError =TrueValidationGroup =提交>

< asp:Button ID =btnUpdaterunat =serverText =UpdateVisible =falseValidationGroup =Submit

OnClick =btnUpdate_ClickOnClientClick =checkDate( ); />

< asp:Label ID =lblMessagerunat =serverText =>


< asp:GridView ID =grdappointmentrunat =serverAutoGenerateColumns =False

onrowcommand =grdappointment_RowCommand

onrowediting =grdappointment_RowEditing

onrowdeleting =grdappointment_RowDeleting>

< columns> < asp:TemplateField HeaderText =UserName>

< edititemtemplate>



< asp:TextBox ID =TextBox1 runat =serverEnabled =falseText ='<%#Bind(Username)%>'>



< itemtemplate>

< asp:Label ID =Label1runat =serverText ='<%#Bind(Username)%>'>





< asp:TemplateField HeaderText =PatientId>

< itemtemplate>

< asp :Label ID =lblgrdPatientIdrunat =serverText ='<%#Bind(PatientId)%>'Enabled =false>



< edititemtemplate>

< asp:TextBox ID =txtgrdPatientIdEnabled =falserunat = serverText ='<%#Bind(PatientId)%>'>





< asp: TemplateField HeaderText =PatientName>

< itemtemplate>

< asp:Label ID =lblgrdPatientNamerunat =serverText ='<%#绑定(PatientName)%>'>



< edititemtemplate>

< asp:TextBox ID =txtgrdPatientName Enabled =falserunat =serverText ='<%#Bind(PatientName)%>'>





< asp:TemplateField HeaderText =AppointmentReason>

< itemtemplate>

< asp:Label ID =lblgrdAppointmentReasonrunat =server Text ='<%#Bind(AppointmentReason)%>'>



< edititemtemplate>

< asp:TextBox ID =txtgrdAppointmentReasonrunat =serverEnabled =false

Text ='< %#Bind(AppointmentReason)%>'>





< asp:TemplateField HeaderText =Email>

< itemtemplate>

< asp:Label ID =lblgrdEmailrunat =serverText ='<%#Bind(Email)%> ;'>



< edititemtemplate>

< asp:TextBox ID =txtgrdEmailEnabled =falserunat =服务器Text ='<%#Bind(Email)%>'>





< asp:TemplateField HeaderText =MobileNo>

< itemtemplate>

< asp:Label ID =lblgrdMobileNorunat =serverText ='<%#Bind(MobileNo)%>'>



< edititemtemplate>

< asp:TextBox ID =txtgrdMobileNoEnabled =falserunat =serverText ='<%#Bind(MobileNo)%>'> ;





< asp:TemplateField HeaderText =Createddate>

< itemtemplate>

< asp:Label ID =lblgrdCreateddaterunat =serverText ='<%#Bind(Createddate)%>'>



< edititemtemplate>

< asp:TextBox ID =txtgrdCreateddateEnabled =falserunat =serverText ='<%#Bind(Createddate )%>'>





< asp:TemplateField HeaderText =AppointmentDate>

< itemtemplate>

< asp:Label ID =lblgrdAppointmentDaterunat =serverText ='< %#Bind(AppointmentDate)%>'>



< edititemtemplate>

< asp:TextBox ID = txtgrdAppointmentDateEnabled =falserunat =serverText ='<%#Bind(AppointmentDate)%>'>





< asp:TemplateField HeaderText =Edit>

< itemtemplate>

<% - < asp:Button ID = editbtnrunat =serverCommandName =EditCommandArgument ='<%#Eval(PatientId)%>'

CausesValidation =falseText =EditToolTip =编辑/> - %>

< asp:LinkBut​​ton ID =lnkbtnrunat =serverCommandName =EditCommandArgument ='<%#Eval(PatientId)%>'Text =Edit>





< asp:TemplateField HeaderText =删除>

< itemtemplate>

< asp:LinkBut​​ton ID =LinkBut​​ton2runat =serverCausesValidation =FalseCommandArgument ='<%#Eval(PatientId)%>'

CommandName =DeleteOnClientClick =javascript:return ConfirmOnDelete()Text =删除>









<%----%>
<%----%>
Welcome<asp:Label ID="lblUserName" runat="server" Text=""> <asp:Label ID="lblPassword" runat="server" Text="">
<asp:Label ID="lblPatientName" runat="server" Text="Patient Name">
<asp:TextBox ID="txtPatientName" runat="server" MaxLength="24">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtPatientName"
ErrorMessage="Please Fill Patient Name" SetFocusOnError="True" ValidationGroup="Submit">
<asp:FilteredTextBoxExtender ID="FilteredTextBoxExtender2" runat="server" TargetControlID="txtPatientName" FilterType="UppercaseLetters,LowercaseLetters" FilterMode="InvalidChars" InvalidChars="~!#$%^&*()_=-:{}?/.,1234567890">
<asp:Label ID="lblAppointmentReason" runat="server" Text="Appointment Reason">
<asp:TextBox ID="txtAppointmentReason" runat="server" MaxLength="50">
<asp:FilteredTextBoxExtender ID="FilteredTextBoxExtender3" runat="server" TargetControlID="txtAppointmentReason" FilterType="UppercaseLetters,LowercaseLetters" FilterMode="InvalidChars" InvalidChars="~!#$%^&*()_=-:{}?/.,1234567890">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtAppointmentReason"
ErrorMessage="Please Fill Appointmet Reason " SetFocusOnError="True" ValidationGroup="Submit">
<asp:Label ID="lblAppointmentType" runat="server" Text="Appointment Type"> <asp:TextBox ID="txtAppointmentType" runat="server" MaxLength="30">
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtAppointmentType"
ErrorMessage="Please Fill Appointment Type" SetFocusOnError="True"
ValidationGroup="Submit">
<asp:Label ID="lblLocation" runat="server" Text="Location"><asp:TextBox ID="txtLocation" runat="server" MaxLength="30">
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txtLocation" ErrorMessage="Please fill Location"
SetFocusOnError="True" ValidationGroup="Submit">
<asp:Label ID="lblDate" runat="server" Text="Appointment Date">
<asp:TextBox ID="txtAppointmentDate" runat="server" AutoPostBack="true">
<asp:ImageButton ID="imgButton" runat="server" ImageUrl="~/images/kkalendari.png"
ImageAlign="Middle" />
<asp:CalendarExtender ID="CalendarExtender1" runat="server" PopupButtonID="imgButton"
TargetControlID="txtAppointmentDate" Format="dd/MM/yyyy">

<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtAppointmentDate"
ErrorMessage="Please Fill Appointment Date" SetFocusOnError="True" ValidationGroup="Submit">
<asp:Label ID="lblEmail" runat="server" Text="Email">
<asp:TextBox ID="txtEmail" runat="server">
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="txtEmail"
ErrorMessage="Please Fill Email Id" SetFocusOnError="True" ValidationGroup="Submit">
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtEmail"
ErrorMessage="Please Fill Valid Email" SetFocusOnError="True" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ValidationGroup="Submit">
<asp:Label ID="lblMobileNo" runat="server" Text="Mobile No.">
<asp:TextBox ID="txtMobileNo" runat="server" MaxLength="10">
<asp:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" TargetControlID="txtMobileNo"
FilterType="Numbers">

<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="txtMobileNo"
ErrorMessage="Please Fill Mobile No" SetFocusOnError="True" ValidationGroup="Submit">
<asp:Button ID="btnUpdate" runat="server" Text="Update" Visible="false" ValidationGroup="Submit"
OnClick="btnUpdate_Click" OnClientClick="checkDate();" />
<asp:Label ID="lblMessage" runat="server" Text="">

<asp:GridView ID="grdappointment" runat="server" AutoGenerateColumns="False"
onrowcommand="grdappointment_RowCommand"
onrowediting="grdappointment_RowEditing"
onrowdeleting="grdappointment_RowDeleting">
<columns> <asp:TemplateField HeaderText="UserName">
<edititemtemplate>

<asp:TextBox ID="TextBox1" runat="server" Enabled="false" Text='<%# Bind("Username") %>'>

<itemtemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Username") %>'>


<asp:TemplateField HeaderText="PatientId">
<itemtemplate>
<asp:Label ID="lblgrdPatientId" runat="server" Text='<%# Bind("PatientId") %>' Enabled="false">

<edititemtemplate>
<asp:TextBox ID="txtgrdPatientId" Enabled="false" runat="server" Text='<%# Bind("PatientId") %>'>


<asp:TemplateField HeaderText="PatientName">
<itemtemplate>
<asp:Label ID="lblgrdPatientName" runat="server" Text='<%# Bind("PatientName") %>'>

<edititemtemplate>
<asp:TextBox ID="txtgrdPatientName" Enabled="false" runat="server" Text='<%# Bind("PatientName") %>'>


<asp:TemplateField HeaderText="AppointmentReason">
<itemtemplate>
<asp:Label ID="lblgrdAppointmentReason" runat="server" Text='<%# Bind("AppointmentReason") %>'>

<edititemtemplate>
<asp:TextBox ID="txtgrdAppointmentReason" runat="server" Enabled="false"
Text='<%# Bind("AppointmentReason") %>'>


<asp:TemplateField HeaderText="Email">
<itemtemplate>
<asp:Label ID="lblgrdEmail" runat="server" Text='<%# Bind("Email") %>'>

<edititemtemplate>
<asp:TextBox ID="txtgrdEmail" Enabled="false" runat="server" Text='<%# Bind("Email") %>'>


<asp:TemplateField HeaderText="MobileNo">
<itemtemplate>
<asp:Label ID="lblgrdMobileNo" runat="server" Text='<%# Bind("MobileNo") %>'>

<edititemtemplate>
<asp:TextBox ID="txtgrdMobileNo" Enabled="false" runat="server" Text='<%# Bind("MobileNo") %>'>


<asp:TemplateField HeaderText="Createddate">
<itemtemplate>
<asp:Label ID="lblgrdCreateddate" runat="server" Text='<%# Bind("Createddate") %>'>

<edititemtemplate>
<asp:TextBox ID="txtgrdCreateddate" Enabled="false" runat="server" Text='<%# Bind("Createddate") %>'>


<asp:TemplateField HeaderText="AppointmentDate">
<itemtemplate>
<asp:Label ID="lblgrdAppointmentDate" runat="server" Text='<%# Bind("AppointmentDate") %>'>

<edititemtemplate>
<asp:TextBox ID="txtgrdAppointmentDate" Enabled="false" runat="server" Text='<%# Bind("AppointmentDate") %>'>


<asp:TemplateField HeaderText="Edit">
<itemtemplate>
<%-- <asp:Button ID="editbtn" runat="server" CommandName="Edit" CommandArgument='<%#Eval("PatientId")%>'
CausesValidation="false" Text="Edit" ToolTip="Edit" />--%>
<asp:LinkButton ID="lnkbtn" runat="server" CommandName="Edit" CommandArgument='<%#Eval("PatientId")%>' Text="Edit">


<asp:TemplateField HeaderText="Delete">
<itemtemplate>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandArgument='<%#Eval("PatientId")%>'
CommandName="Delete" OnClientClick="javascript:return ConfirmOnDelete()" Text="Delete">



推荐答案

%^& *()_ = - :{}?/。,1234567890>

< td>< asp:Label ID =lblAppointmentReasonrunat =serverText =Appointment Reason>

< asp:TextBox ID =txtAppointmentReasonrunat =serverMaxLength =50>

< asp:FilteredTextBoxExtender ID =FilteredTextBoxExtender3runat =serverTargetControlID = txtAppointmentReasonFilterType =UppercaseLetters,LowercaseLettersFilterMode =InvalidCharsInvalidChars =〜!#
%^&*()_=-:{}?/.,1234567890">
<asp:Label ID="lblAppointmentReason" runat="server" Text="Appointment Reason">
<asp:TextBox ID="txtAppointmentReason" runat="server" MaxLength="50">
<asp:FilteredTextBoxExtender ID="FilteredTextBoxExtender3" runat="server" TargetControlID="txtAppointmentReason" FilterType="UppercaseLetters,LowercaseLetters" FilterMode="InvalidChars" InvalidChars="~!#


%^& *()_ = - :{}?/。,1234567890 >

< asp:RequiredFieldValidator ID =RequiredFieldValidator2runat =serverControlToValidate =txtAppointmentReason

ErrorMessage =请填写Appointmet ReasonSetFocusOnError =真ValidationGroup =提交>

< asp:Label ID =lblAppointmentTyperunat =serverText =Appointment类型>
< asp:TextBox ID =txtAppointmentTyperunat =serverMaxLength =30>

< asp:RequiredFieldValidator ID =RequiredFieldValidator3 runat =server

ControlToValidate =txtAppointmentType

ErrorMessage =请填写预约类型SetFocusOnError =True

ValidationGroup = 提交>

< asp:标签ID =lblLocationrunat =serverText =Location> < asp:TextBox ID =txtLocationrunat =serverMaxLength =30>

< asp:RequiredFieldValidator ID =RequiredFieldValidator4runat =server

ControlToValidate =txtLocationErrorMessage =请填写位置

SetFocusOnError =TrueValidationGroup =提交>

< asp:Label ID =lblDaterunat =serverText =约会日期>

< asp:TextBox ID =txtAppointmentDaterunat =serverAutoPostBack =true>

< asp:ImageButton ID =imgButtonrunat =serverImageUrl =〜/ images / kkalendari.png

ImageAlign =中间/>

< asp:CalendarExtender ID =CalendarExtender1runat =serverPopupButtonID =imgButton

TargetControlID =txtAppointmentDateFormat =dd / MM / yyyy>



< asp:RequiredFieldValidator ID =RequiredFieldValidator5 runat =serverControlToValidate =txtAppointmentDate

ErrorMessage =请填写预约日期SetFocusOnError =TrueValidationGroup =提交>

< asp:Label ID =lblEmailrunat =serverText =Email>

< asp:TextBox ID =txtEmailrunat =server>

< asp:RequiredFieldValidator ID =RequiredFieldValidator6runat =serverControlToValidate =txtEmail

ErrorMessage =请填写电子邮件IDSetFocusOnError =TrueValidationGroup =提交>

< asp:RegularExpressionValidator ID =RegularExpressionValidator1runat =serverControlToValidate =txtEmail

ErrorMessage =请填写有效的电子邮件SetFocusOnError =TrueValidationExpression =\ w +([ - +。'] \ w +)* @ \ w +([ - 。] \w +)* \.\\\ +([ - 。] \ w +)*

ValidationGroup =提交>

< asp:Label ID =lblMobileNorunat =serverText =Mobile No.>

< ASP:TEXTB ox ID =txtMobileNorunat =serverMaxLength =10>

< asp:FilteredTextBoxExtender ID =FilteredTextBoxExtender1runat =serverTargetControlID =txtMobileNo

FilterType =Numbers>



< asp:RequiredFieldValidator ID =RequiredFieldValidator7runat =serverControlToValidate =txtMobileNo

ErrorMessage =请填写手机号码SetFocusOnError =TrueValidationGroup =提交>

< asp:Button ID =btnUpdaterunat =serverText =UpdateVisible =falseValidationGroup =Submit

OnClick =btnUpdate_ClickOnClientClick =checkDate( ); />

< asp:Label ID =lblMessagerunat =serverText =>

< asp:GridView ID =grdappointmentrunat =serverAutoGenerateColumns =False

onrowcommand =grdappointment_RowCommand

onrowediting =grdappointment_RowEditing

onrowdeleting =grdappointment_RowDeleting>

< columns> < asp:TemplateField HeaderText =UserName>

< edititemtemplate>



< asp:TextBox ID =TextBox1 runat =serverEnabled =falseText ='<%#Bind(Username)%>'>



< itemtemplate>

< asp:Label ID =Label1runat =serverText ='<%#Bind(Username)%>'>





< asp:TemplateField HeaderText =PatientId>

< itemtemplate>

< asp :Label ID =lblgrdPatientIdrunat =serverText ='<%#Bind(PatientId)%>'Enabled =false>



< edititemtemplate>

< asp:TextBox ID =txtgrdPatientIdEnabled =falserunat = serverText ='<%#Bind(PatientId)%>'>





< asp: TemplateField HeaderText =PatientName>

< itemtemplate>

< asp:Label ID =lblgrdPatientNamerunat =serverText ='<%#绑定(PatientName)%>'>



< edititemtemplate>

< asp:TextBox ID =txtgrdPatientName Enabled =falserunat =serverText ='<%#Bind(PatientName)%>'>





< asp:TemplateField HeaderText =AppointmentReason>

< itemtemplate>

< asp:Label ID =lblgrdAppointmentReasonrunat =server Text ='<%#Bind(AppointmentReason)%>'>



< edititemtemplate>

< asp:TextBox ID =txtgrdAppointmentReasonrunat =serverEnabled =false

Text ='< %#Bind(AppointmentReason)%>'>





< asp:TemplateField HeaderText =Email>

< itemtemplate>

< asp:Label ID =lblgrdEmailrunat =serverText ='<%#Bind(Email)%> ;'>



< edititemtemplate>

< asp:TextBox ID =txtgrdEmailEnabled =falserunat =服务器Text ='<%#Bind(Email)%>'>





< asp:TemplateField HeaderText =MobileNo>

< itemtemplate>

< asp:Label ID =lblgrdMobileNorunat =serverText ='<%#Bind(MobileNo)%>'>



< edititemtemplate>

< asp:TextBox ID =txtgrdMobileNoEnabled =falserunat =serverText ='<%#Bind(MobileNo)%>'> ;





< asp:TemplateField HeaderText =Createddate>

< itemtemplate>

< asp:Label ID =lblgrdCreateddaterunat =serverText ='<%#Bind(Createddate)%>'>



< edititemtemplate>

< asp:TextBox ID =txtgrdCreateddateEnabled =falserunat =serverText ='<%#Bind(Createddate )%>'>





< asp:TemplateField HeaderText =AppointmentDate>

< itemtemplate>

< asp:Label ID =lblgrdAppointmentDaterunat =serverText ='< %#Bind(AppointmentDate)%>'>



< edititemtemplate>

< asp:TextBox ID = txtgrdAppointmentDateEnabled =falserunat =serverText ='<%#Bind(AppointmentDate)%>'>





< asp:TemplateField HeaderText =Edit>

< itemtemplate>

<% - < asp:Button ID = editbtnrunat =serverCommandName =EditCommandArgument ='<%#Eval(PatientId)%>'

CausesValidation =falseText =EditToolTip =编辑/> - %>

< asp:LinkBut​​ton ID =lnkbtnrunat =serverCommandName =EditCommandArgument ='<%#Eval(PatientId)%>'Text =Edit>





< asp:TemplateField HeaderText =删除>

< itemtemplate>

< asp:LinkBut​​ton ID =LinkBut​​ton2runat =serverCausesValidation =FalseCommandArgument ='<%#Eval(PatientId)%>'

CommandName =DeleteOnClientClick =javascript:return ConfirmOnDelete()Text =删除>







%^&*()_=-:{}?/.,1234567890">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtAppointmentReason"
ErrorMessage="Please Fill Appointmet Reason " SetFocusOnError="True" ValidationGroup="Submit">
<asp:Label ID="lblAppointmentType" runat="server" Text="Appointment Type"> <asp:TextBox ID="txtAppointmentType" runat="server" MaxLength="30">
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtAppointmentType"
ErrorMessage="Please Fill Appointment Type" SetFocusOnError="True"
ValidationGroup="Submit">
<asp:Label ID="lblLocation" runat="server" Text="Location"><asp:TextBox ID="txtLocation" runat="server" MaxLength="30">
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txtLocation" ErrorMessage="Please fill Location"
SetFocusOnError="True" ValidationGroup="Submit">
<asp:Label ID="lblDate" runat="server" Text="Appointment Date">
<asp:TextBox ID="txtAppointmentDate" runat="server" AutoPostBack="true">
<asp:ImageButton ID="imgButton" runat="server" ImageUrl="~/images/kkalendari.png"
ImageAlign="Middle" />
<asp:CalendarExtender ID="CalendarExtender1" runat="server" PopupButtonID="imgButton"
TargetControlID="txtAppointmentDate" Format="dd/MM/yyyy">

<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtAppointmentDate"
ErrorMessage="Please Fill Appointment Date" SetFocusOnError="True" ValidationGroup="Submit">
<asp:Label ID="lblEmail" runat="server" Text="Email">
<asp:TextBox ID="txtEmail" runat="server">
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="txtEmail"
ErrorMessage="Please Fill Email Id" SetFocusOnError="True" ValidationGroup="Submit">
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtEmail"
ErrorMessage="Please Fill Valid Email" SetFocusOnError="True" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ValidationGroup="Submit">
<asp:Label ID="lblMobileNo" runat="server" Text="Mobile No.">
<asp:TextBox ID="txtMobileNo" runat="server" MaxLength="10">
<asp:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" TargetControlID="txtMobileNo"
FilterType="Numbers">

<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="txtMobileNo"
ErrorMessage="Please Fill Mobile No" SetFocusOnError="True" ValidationGroup="Submit">
<asp:Button ID="btnUpdate" runat="server" Text="Update" Visible="false" ValidationGroup="Submit"
OnClick="btnUpdate_Click" OnClientClick="checkDate();" />
<asp:Label ID="lblMessage" runat="server" Text="">
<asp:GridView ID="grdappointment" runat="server" AutoGenerateColumns="False"
onrowcommand="grdappointment_RowCommand"
onrowediting="grdappointment_RowEditing"
onrowdeleting="grdappointment_RowDeleting">
<columns> <asp:TemplateField HeaderText="UserName">
<edititemtemplate>

<asp:TextBox ID="TextBox1" runat="server" Enabled="false" Text='<%# Bind("Username") %>'>

<itemtemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Username") %>'>


<asp:TemplateField HeaderText="PatientId">
<itemtemplate>
<asp:Label ID="lblgrdPatientId" runat="server" Text='<%# Bind("PatientId") %>' Enabled="false">

<edititemtemplate>
<asp:TextBox ID="txtgrdPatientId" Enabled="false" runat="server" Text='<%# Bind("PatientId") %>'>


<asp:TemplateField HeaderText="PatientName">
<itemtemplate>
<asp:Label ID="lblgrdPatientName" runat="server" Text='<%# Bind("PatientName") %>'>

<edititemtemplate>
<asp:TextBox ID="txtgrdPatientName" Enabled="false" runat="server" Text='<%# Bind("PatientName") %>'>


<asp:TemplateField HeaderText="AppointmentReason">
<itemtemplate>
<asp:Label ID="lblgrdAppointmentReason" runat="server" Text='<%# Bind("AppointmentReason") %>'>

<edititemtemplate>
<asp:TextBox ID="txtgrdAppointmentReason" runat="server" Enabled="false"
Text='<%# Bind("AppointmentReason") %>'>


<asp:TemplateField HeaderText="Email">
<itemtemplate>
<asp:Label ID="lblgrdEmail" runat="server" Text='<%# Bind("Email") %>'>

<edititemtemplate>
<asp:TextBox ID="txtgrdEmail" Enabled="false" runat="server" Text='<%# Bind("Email") %>'>


<asp:TemplateField HeaderText="MobileNo">
<itemtemplate>
<asp:Label ID="lblgrdMobileNo" runat="server" Text='<%# Bind("MobileNo") %>'>

<edititemtemplate>
<asp:TextBox ID="txtgrdMobileNo" Enabled="false" runat="server" Text='<%# Bind("MobileNo") %>'>


<asp:TemplateField HeaderText="Createddate">
<itemtemplate>
<asp:Label ID="lblgrdCreateddate" runat="server" Text='<%# Bind("Createddate") %>'>

<edititemtemplate>
<asp:TextBox ID="txtgrdCreateddate" Enabled="false" runat="server" Text='<%# Bind("Createddate") %>'>


<asp:TemplateField HeaderText="AppointmentDate">
<itemtemplate>
<asp:Label ID="lblgrdAppointmentDate" runat="server" Text='<%# Bind("AppointmentDate") %>'>

<edititemtemplate>
<asp:TextBox ID="txtgrdAppointmentDate" Enabled="false" runat="server" Text='<%# Bind("AppointmentDate") %>'>


<asp:TemplateField HeaderText="Edit">
<itemtemplate>
<%-- <asp:Button ID="editbtn" runat="server" CommandName="Edit" CommandArgument='<%#Eval("PatientId")%>'
CausesValidation="false" Text="Edit" ToolTip="Edit" />--%>
<asp:LinkButton ID="lnkbtn" runat="server" CommandName="Edit" CommandArgument='<%#Eval("PatientId")%>' Text="Edit">


<asp:TemplateField HeaderText="Delete">
<itemtemplate>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandArgument='<%#Eval("PatientId")%>'
CommandName="Delete" OnClientClick="javascript:return ConfirmOnDelete()" Text="Delete">




这篇关于如何处理此行编辑错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆