1
Answer

C# help

Tom white

Tom white

11y
1.5k
1
can any one help me with this please?

OO Programming
Create an appropriate GUI to enter information for at least 10 students. For each student you have to enter the following information: student ID number, student's first and last names, date of birth consisting of day, month and year and an average mark. Check for correctness the input data (e.g. the ID number is a positive number, the marks are integer numbers between 0 and 100, the date of birth must be a valid date, etc.). Make sure the program processes only correct information about each student.

Create a separate class Student, containing student's information in the form: student ID number, student's first and last name, day, month and year of birth and average mark. The class should have constructors, properties and methods. Store the information about all the students in an array of type Student. After reading from the GUI the information about a particular student, create an object of class Student (element of the array) with the relevant constructor.
The user would like to be able to find the first three students with the highest marks and display information about them sorted by their dates of birth. Provide the user with an appropriate GUI (e.g. a message box) to display the required information.

I am using visual studio professional 2010 

Thanks
Answers (1)
1
Satyapriya Nayak

Satyapriya Nayak

NA 53k 8m 11y
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Select_row_value_gridview_dropdown._Default" %>

<!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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateSelectButton="true"  AutoGenerateColumns="true"
        BackColor="#CCFFCC" Font-Bold="False" ForeColor="Maroon"
            onselectedindexchanged="GridView1_SelectedIndexChanged">
        <AlternatingRowStyle BackColor="#FFCC66" />
    </asp:GridView>
    <br />
    <asp:Label ID="lb1" runat="server" Text="ID : " Font-Bold="True" Width="100px"></asp:Label>
        <asp:DropDownList ID="ddl_id" runat="server">
        </asp:DropDownList>
    <br />
    <br />
    <asp:Label ID="lb3" runat="server" Text="NAME : " Font-Bold="True"
        Width="100px"></asp:Label>
    <asp:DropDownList ID="ddl_name" runat="server">
        </asp:DropDownList>
    <br />
    <br />
    <asp:Label ID="lb5" runat="server" Text="ADDRESS : " Font-Bold="True"
        Width="100px"></asp:Label>
   <asp:DropDownList ID="ddl_address" runat="server">
        </asp:DropDownList>
    <br />
    <br />
    <asp:Label ID="lb7" runat="server" Text="MARK : " Font-Bold="True"
        Width="100px"></asp:Label>
    <asp:DropDownList ID="ddl_marks" runat="server">
        </asp:DropDownList>
    <br />
    <br />
    <asp:Label ID="lb9" runat="server" Text="YEAR : " Font-Bold="True"
        Width="100px"></asp:Label>
   <asp:DropDownList ID="ddl_year" runat="server">
        </asp:DropDownList>
    </div>
    </form>
</body>
</html>




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;
using System.Data.SqlClient;
namespace Select_row_value_gridview_dropdown
{
    public partial class _Default : System.Web.UI.Page
    {
        string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        string str;
        SqlCommand com;
        SqlDataAdapter sqlda;
        DataSet ds;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bindgrid();
            }
        }
        void bindgrid()
        {
            SqlConnection con = new SqlConnection(strConnString);
            con.Open();
            str = "select * from student";
            com = new SqlCommand(str, con);
            sqlda = new SqlDataAdapter(com);
            ds = new DataSet();
            sqlda.Fill(ds, "student");
            GridView1.DataSource = ds;
            GridView1.DataMember = "student";
            GridView1.DataBind();
            con.Close();
        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            ddl_id.Items.Clear();
            ddl_name.Items.Clear();
            ddl_address.Items.Clear();
            ddl_marks.Items.Clear();
            ddl_year.Items.Clear();

            ddl_id.Items.Add(GridView1.SelectedRow.Cells[1].Text);
            ddl_name.Items.Add(GridView1.SelectedRow.Cells[2].Text);
            ddl_address.Items.Add(GridView1.SelectedRow.Cells[3].Text);
            ddl_marks.Items.Add(GridView1.SelectedRow.Cells[4].Text);
            ddl_year.Items.Add(GridView1.SelectedRow.Cells[5].Text);
        }
    }
}

Accepted
0
AbhiPriya M V

AbhiPriya M V

NA 80 24.5k 11y
got it SATYAPRIYA... thank u thank u!!!!
0
AbhiPriya M V

AbhiPriya M V

NA 80 24.5k 11y
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { TextBox5.Text = GridView1.SelectedRow.Cells[1].Text; TextBox2.Text = GridView1.SelectedRow.Cells[2].Text; TextBox3.Text = GridView1.SelectedRow.Cells[3].Text; TextBox4.Text = GridView1.SelectedRow.Cells[3].Text; } using this code for displaying values of gridview rows in textbox, lyk dis need to display selected gridview values in dropdown.
0
Vishal Gilbile

Vishal Gilbile

NA 13.9k 2.9m 11y
Hi,
     In that case you need to make use of GridView SelectedIndexChanging event of your gridview control. Below is the code for the same.

protected void gvwGrid_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        GridViewRow row = (GridViewRow)gvwGrid.Rows[e.NewSelectedIndex];
        for (int i = 0; i < row.Cells.Count; i++)
        {
            Response.Write(row.Cells[i].Text);
        }
    }

In the above code I'm just displaying the values. you can do whatever is your scenario.


Hope that solves your problem.

With Regards,
Vishal Gilbile.
0
AbhiPriya M V

AbhiPriya M V

NA 80 24.5k 11y
thank u for ur reply.. using AutoGenerateSelectButton in gridview properties.
0
Vishal Gilbile

Vishal Gilbile

NA 13.9k 2.9m 11y
Hello Friend,
                For selection which control you are using I mean whether you are using a Checkbox or a link button and also whether your gridview is making use of Template Field or not.



With Regards,
Vishal Gilbile.