Rini

Rini

  • 1.5k
  • 204
  • 31.7k

error

Aug 21 2013 6:02 AM
please look my code
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("<script>alert('Saved Successfully')</script>");
                    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" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Division</title>
    <link href="../Style%20Sheets/Stylesheet1.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .style16
        {
            width: 196px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div class="class1">
    <h2><b>Division</b></h2>
    </div>
    <div class="left">
    <img src="../Images/361_logo.jpg" width="200px" height="150px" />
     <h4>Upcoming Events</h4>
    <marquee onmouseover="stop()" onmouseout="start()" direction="up"><strong> * Admission started </strong><br/>
<strong> * Next PTA meeting held on 11/9/2013</strong><br/>
<strong> * Next CE text conducted on 1/9/2013</strong>
<strong> * Spectra, 2013 ..... </strong>
<strong> *Check out our montly newsletter</strong>
</marquee>
    </div>
    <div class="right">
        <uc1:WebUserControl1 ID="WebUserControl11" runat="server" /> 
    </div>
    <div class="class2">
    <img src="../Images/bigstock-Classroom-Painting-In-Kinderga-4521203.jpg"  height="300px" width="750px" />
        <asp:MultiView ID="MultiView1" runat="server">
            <asp:View ID="View1" runat="server">
                <table class="style1">
                    <tr>
                        <td class="style16">
                            <asp:Label ID="Label1" runat="server" Font-Bold="True" Text="ClassName"></asp:Label>
                        </td>
                        <td>
                            <asp:DropDownList ID="ddlname" runat="server" Width="128px">
                            </asp:DropDownList>
                            <asp:RequiredFieldValidator ID="rgbval1" runat="server"
                                ControlToValidate="ddlname" ErrorMessage="*" InitialValue="--select--"
                                ToolTip="Please select the ClassName" ValidationGroup="a"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td class="style16">
                            <asp:Label ID="Label2" runat="server" Font-Bold="True" Text="Division Name"></asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="txtdiv" runat="server"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="reqval" runat="server"
                                ControlToValidate="txtdiv" Display="Dynamic" ErrorMessage="*"
                                ToolTip="Enter the divisionName" ValidationGroup="a"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                </table>
                <br />
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:Button ID="btnsave" runat="server" Text="Save" ValidationGroup="a"
                    onclick="btnsave_Click" />
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:Button ID="btnclear" runat="server" Text="Clear"
                    onclick="btnclear_Click" />
                <br />
                <br />
                <br />
                <fieldset>
                        <legend>Division</legend>
                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                            AllowPaging="True" onpageindexchanging="GridView1_PageIndexChanging">
                    <Columns>
                        <asp:BoundField DataField="className" HeaderText="className" />
                        <asp:BoundField DataField="divisionName" HeaderText="divisionName" />
                        <asp:CommandField ShowSelectButton="True" />
                        <asp:CommandField ShowDeleteButton="True" />
                    </Columns>
                </asp:GridView>
                </fieldset>
                <br />
                <br />
                <br />
                <br />
                <br />
                <br />
                <br />
                <br />
                <br />
                <br />
                <br />
                <br />
                <br />
                <br />
                <br />
                <br />
            </asp:View>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <br />
            <br />
        </asp:MultiView>
    </div>
    </form>
</body>
</html>





Answers (4)