473,395 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Input the scores of a subject

ad
I want to create a input form to Input the scores of a subject in a class.
There are about 30 students in a class.
I want to desplay 30 textboxes in a form at a time.
The user can intput the score of all student at a time and press a summit
button to update to database.

How can I do that?

Nov 19 '05 #1
2 1371
Basically,
1) create a webform
2) youll have a code that fires when the submit button is clicked which
whill insert data into into the database using a sql statement.

There are lots of examples of manipulating data using asp.net on the web -
google and you'll find answers galore
"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:OT**************@TK2MSFTNGP10.phx.gbl...
I want to create a input form to Input the scores of a subject in a class.
There are about 30 students in a class.
I want to desplay 30 textboxes in a form at a time.
The user can intput the score of all student at a time and press a summit
button to update to database.

How can I do that?


Nov 19 '05 #2
If you know the list of the students ahead of time (day from your DB) then
you can build a DataSet that has template columns for all of the updatable
fields. You'd then add a button to your form and handle the button's click
event. In the event handler you'd need to iterate over each DataGridRow in
the DataGrid.Rows collection and use FindControl() to access the <asp:TextBox>
or whatever controls you has in the ItemTemplate in your DataGrid. Once you
had those controls, you could then build your update or insert statements
back to the database. Here's a small snippet that might help give you an
idea:
<asp:DataGrid OnItemDataBound="OnItem" CellSpacing="0" CellPadding="2"
DataKeyField="ID" AutoGenerateColumns="False" Runat="server" ID="dg">
<HeaderStyle Wrap="False"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="Guest">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "LastName")
%>
,
<%# DataBinder.Eval(Container.DataItem, "FirstName")
%>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Choose a Meal">
<ItemTemplate>
<asp:DropDownList SelectedIndex='<%# DataBinder.Eval(Container.DataItem,
"Meal") %>' Runat="server" ID="_meal">
<asp:ListItem Value="0">Beef</asp:ListItem>
<asp:ListItem Value="1">Fish</asp:ListItem>
<asp:ListItem Value="2">Vegetarian</asp:ListItem>
<asp:ListItem Value="3">Child Menu</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Any Food Allergies?">
<ItemTemplate>
<asp:CheckBox Checked='<%# DataBinder.Eval(Container.DataItem,
"Special") %>' Runat="server" ID="_special" Text="Check if Yes">
</asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Comments or Details about
Food Allergies">
<ItemTemplate>
<asp:TextBox TextMode="MultiLine" MaxLength="1000"
Width="100%" Runat="server" ID="_comment" Text='<%# DataBinder.Eval(Container.DataItem,
"Comment") %>'>
</asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>

protected void _button_Click(object sender, System.EventArgs e)
{
foreach (DataGridItem r in dg.Items)
{
DropDownList list = r.Cells[1].FindControl("_meal") as DropDownList;
if (list == null) continue;

CheckBox check = r.Cells[2].FindControl("_special") as CheckBox;
if (check == null) continue;

TextBox text = r.Cells[3].FindControl("_comment") as TextBox;
if (text == null) continue;

// build SQL to go update the database from the control's
values
}
}
-Brock
DevelopMentor
http://staff.develop.com/ballen
I want to create a input form to Input the scores of a subject in a
class.
There are about 30 students in a class.
I want to desplay 30 textboxes in a form at a time.
The user can intput the score of all student at a time and press a
summit
button to update to database.
How can I do that?


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: a | last post by:
(I've reached that familiar place where I've got a nagging little problem in a program I'm writing but I've been staring at code for too long and I probably wouldn't be able to recognize the answer...
3
by: Irene | last post by:
Hi all, I have set up a simple VB program (and later on an ASP interface) to manage an Athletics database. I'm using Access 2000. To simplify, I have the Athlets, the Competitions and the...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
1
by: waldoruns | last post by:
I need help to finish this code.....Here is what I got so far...... /Read in test scores and output total number of scores, total number of each letter grade, //percentage of total for each...
3
by: Akinyemi | last post by:
I am writing a Visual Basic program for calculating students scores, and also grading the highest 3 scores as "First" , "Second" and "Third" respectively. I have been able to get the program to...
1
by: sacksey | last post by:
Hi. I am new to PHP though i have a small background in C++ (took a intro course in college). I am wondering if this is legal to do: <form action="<? $name = $HTTP_POST_VARS; $fromemail =...
5
by: joestevens232 | last post by:
Ok Im trying to use a struct to take in input from a file "grades.txt" which looks like: Smith 9 9.33 8 10 5.5 8 10 20 47.5 47 45 47.5 48 83 87 100 98 96 100 98 92 88 96 92 86 92 94 100...
1
by: JPhilS | last post by:
Hi to all Webmaster! I have discover this problem when I inserted the scores of the students i a centain subject. I am making a school project with regards to saving students' record. first, I...
1
by: supahsain | last post by:
I got this assignment, and almost have no clue, and my teacher doesn't even teaches us anything This is what i am suppose to do...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.