TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
avijit chatterjee
NA
16
0
ValidatorCalloutExtender not working in gridview....
Aug 28 2010 10:20 AM
hi ...
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---->
<asp:TemplateField HeaderText="Sr No" HeaderStyle-HorizontalAlign="Left" HeaderStyle-VerticalAlign="Top" HeaderStyle-Width="30">
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:Label ID="lbl_srno" runat="server" Text='<%# Eval("srno") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_srno" Enabled="true" runat="server" Text='<%# Eval("srno") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtnew_srno" runat="server" Width="30"></asp:TextBox>
<asp:RequiredFieldValidator ID ="RequiredFieldValidator2"
runat="server"
Display="Dynamic"
EnableClientScript="false"
EnableViewState="false"
ValidationGroup="Group1"
ControlToValidate="txtnew_srno"
ErrorMessage="Inter SrNo."
CssClass="error">
</asp:RequiredFieldValidator>
<AjaxToolkit:ValidatorCalloutExtender ID="ValidatorCalloutExtender2"
runat="server"
TargetControlID="RequiredFieldValidator2"
HighlightCssClass="Highlight"
PopupPosition="TopLeft">
</AjaxToolkit:ValidatorCalloutExtender>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Edit" ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit"></asp:LinkButton>
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update" Text="Update"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False"
CommandName="AddNew" ValidationGroup="Group1" EnableViewState="false" Text="Add New"></asp:LinkButton>
</FooterTemplate>
</asp:TemplateField>
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...
Reply
Answers (
0
)
Load multiple text file in simple Notepad
Move objects with Mouse Drag