using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace SchoolManagement.Designs
{
public partial class Division : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
MultiView1.SetActiveView(View1);
combofill();
gridfill();
}
public void combofill()
{
ClassSP spClass = new ClassSP();
DataTable dtblc = new DataTable();
dtblc = spClass.classViewAll();
ddlname.DataSource = dtblc;
ddlname.DataValueField = "classId";
ddlname.DataTextField = "className";
ddlname.DataBind();
ddlname.Items.Insert(0, "--select--");
}
public void gridfill()
{
DivisionInfo infodivision = new DivisionInfo();
DivisionSP spdivision = new DivisionSP();
DataTable dtbl = new DataTable();
dtbl = spdivision.divisionViewAll();
GridView1.DataSource = dtbl;
GridView1.DataBind();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
gridfill();
}
public void clear()
{
txtdiv.Text = string.Empty;
ddlname.SelectedIndex = 0;
}
protected void btnclear_Click(object sender, EventArgs e)
{
clear();
}
protected void btnsave_Click(object sender, EventArgs e)
{
if (ddlname.SelectedIndex != 0 && txtdiv.Text != string.Empty)
{
DivisionInfo infodivision = new DivisionInfo();
infodivision.classId = decimal.Parse(ddlname.SelectedValue.ToString());
infodivision.divisionName = txtdiv.Text.Trim();
DivisionSP SPDivision = new DivisionSP();
if (btnsave.Text == "Save")
{
SPDivision.divisionAdd(infodivision);
Response.Write("");
gridfill();
}
}
}
}
}
when i click the button save
it will say plese select the field
my aspx code is
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Division.aspx.cs" Inherits="SchoolManagement.Designs.Division" %>
<%@ Register src="../WebUserControl1.ascx" tagname="WebUserControl1" tagprefix="uc1" %>

Iftikar HussainPosted Aug 21, 2013, 6:34 AM
protected void Page_Load(object sender, EventArgs e)
{
MultiView1.SetActiveView(View1);
if(!IsPostBack)
{
combofill();
}
gridfill();
}
Regards,
Iftikar
RiniPosted Aug 21, 2013, 6:20 AM
when i click the save button it will seen
Iftikar HussainPosted Aug 21, 2013, 6:06 AM
Try like this
ControlToValidate="ddlname" ErrorMessage="*" InitialValue="0"
ToolTip="Please select the ClassName" ValidationGroup="a">
Regards,
Iftikar
Sanjeeb LenkaPosted Aug 21, 2013, 6:05 AM
Plz provide the error what you are getting in which line.
as from your code your dropdown val;idation is not working:
change this code:
ToolTip="Please select the ClassName" ValidationGroup="a">
to
ToolTip="Please select the ClassName" ValidationGroup="a">