I am sending .aspx page and code behind page ,where what i want to do is i used RequiredFieldValidator and ValidatorCalloutExtender both and one link is their called AddNew. When user hit the Addnew link and if txt_srno field is empty then requiredfieldvalidator get fire and error message will show.
please someone help me get the answer...
.aspx page---->
runat="server"
Display="Dynamic"
EnableClientScript="false"
EnableViewState="false"
ValidationGroup="Group1"
ControlToValidate="txtnew_srno"
ErrorMessage="Inter SrNo."
CssClass="error">
runat="server"
TargetControlID="RequiredFieldValidator2"
HighlightCssClass="Highlight"
PopupPosition="TopLeft">
CommandName="AddNew" ValidationGroup="Group1" EnableViewState="false" Text="Add New">
codebehind page......
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
ContractorCls cons = new ContractorCls();
TextBox txt_srno = (TextBox)e.Row.FindControl("txt_srno") as TextBox;
DropDownList cmbcontractor_name = e.Row.FindControl("cmbcontractor_name") as DropDownList;
TextBox txtlabour_name = e.Row.FindControl("txtlabour_name") as TextBox;
DropDownList cmbshift = e.Row.FindControl("cmbshift") as DropDownList;
TextBox txtentry_time = e.Row.FindControl("txtentry_time") as TextBox;
TextBox txtexit_time = e.Row.FindControl("txtexit_time") as TextBox;
TextBox txtlocation = e.Row.FindControl("txtlocation") as TextBox;
TextBox txtjob_desc = e.Row.FindControl("txtjob_desc") as TextBox;
TextBox txtstart_time = e.Row.FindControl("txtstart_time") as TextBox;
TextBox txtend_time = e.Row.FindControl("txtend_time") as TextBox;
TextBox txtOT_from = e.Row.FindControl("txtOT_from") as TextBox;
TextBox txtOT_end = e.Row.FindControl("txtOT_end") as TextBox;
TextBox txtOT_reason = e.Row.FindControl("txtOT_reason") as TextBox;
}
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
ContractorCls cons = new ContractorCls();
if (e.CommandName.Equals("AddNew"))
{
TextBox txtnew_srno = (TextBox)GridView1.FooterRow.FindControl("txtnew_srno");
DropDownList cmbnewcontractor_name = (DropDownList)GridView1.FooterRow.FindControl("cmbnewcontractor_name");
TextBox txtnewlabour_name = (TextBox)GridView1.FooterRow.FindControl("txtnewlabour_name");
DropDownList cmbnewshift = (DropDownList)GridView1.FooterRow.FindControl("cmbnewshift");
TextBox txtnewentry_time = (TextBox)GridView1.FooterRow.FindControl("txtnewentry_time");
TextBox txtnewexit_time = (TextBox)GridView1.FooterRow.FindControl("txtnewexit_time");
TextBox txtnewlocation = (TextBox)GridView1.FooterRow.FindControl("txtnewlocation");
TextBox txtnewjob_desc = (TextBox)GridView1.FooterRow.FindControl("txtnewjob_desc");
TextBox txtnewstart_time = (TextBox)GridView1.FooterRow.FindControl("txtnewstart_time");
TextBox txtnewend_time = (TextBox)GridView1.FooterRow.FindControl("txtnewend_time");
TextBox txtnewOT_from = (TextBox)GridView1.FooterRow.FindControl("txtnewOT_from");
TextBox txtnewOT_end = (TextBox)GridView1.FooterRow.FindControl("txtnewOT_end");
TextBox txtnewOT_reason = (TextBox)GridView1.FooterRow.FindControl("txtnewOT_reason");
cons.Insert(Convert.ToInt32(txtnew_srno.Text), cmbnewcontractor_name.SelectedValue, txtnewlabour_name.Text, cmbnewshift.SelectedValue, txtnewentry_time.Text, txtnewexit_time.Text, txtnewlocation.Text, txtnewjob_desc.Text, txtnewstart_time.Text, txtnewend_time.Text, txtnewOT_from.Text, txtnewOT_end.Text, txtnewOT_reason.Text);
fillgrid();
}
}
help me please....
thanks...
Replies
Know the answer? Post it — somebody with the same question will find it here.