Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am developing a webpage where staff are allowed to enter marks of their student based on the roll numbers. I have created a page where staff will have to enter subject code(say std3sec1)and these subject code are unique for all the staff. So when staff enter the subject code, it has to pull all the student who has been registered under that subject code and the staff will able to enter the marks for all those student. For better understanding I will try to give a pictorial rep below
database:
C#
rollnum | Name   | SubjectCode
001	  ABC	   std3sec1
002	  BCD	   std3sec1
003	  HBC	   std3sec2
004	  NCD	   std3sec2

So when the staff enter subject code as std3sec1, the following details has to display in next webform.
C#
name | rollnum | test1 	   | test2 	| Quiz
ABC	001	 staff_ip    staff_ip    staff_ip
BCD	002	 staff_ip    staff_ip    staff_ip


Here, staff_ip stands for the marks which staff has to enter.
My main question is how can i dynamically generate textboxes to have staff enter their student test marks based on the data fetched from the database? If Textboxes are really bad idea, then what should I do to overcome textboxes. Or is there any way where i can use a table form to enter marks?
Thank you.
Posted
Updated 23-Feb-15 20:36pm
v4
Comments
Kornfeld Eliyahu Peter 24-Feb-15 2:35am    
Why TextBox? Use GridView with edit option...
Sinisa Hajnal 24-Feb-15 5:12am    
Use any of the editable template controls: GridView, DataList even Repeater...

1 solution

Use Either gridview1 or gridview2

ASP
<asp:GridView ID="GridView1" runat="server">
          <Columns>
              <asp:CommandField ShowEditButton="True" />
          </Columns>
      </asp:GridView>
      <br />
      <br />



      <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False">
          
<Columns>
              <asp:BoundField HeaderText="Roll No" DataField="RollNo"/>
              <asp:TemplateField HeaderText="Marks1">
              <ItemTemplate>
              <asp:TextBox ID="tb1" runat="server"> </asp:TextBox>
              </ItemTemplate>
              </asp:TemplateField>

              <asp:TemplateField HeaderText="Marks2">
              <ItemTemplate>
              <asp:TextBox ID="tb2" runat="server"> </asp:TextBox>
              </ItemTemplate>
              </asp:TemplateField>

              <asp:TemplateField HeaderText="Marks2">
              <ItemTemplate>
              <asp:TextBox ID="tb3" runat="server"> </asp:TextBox>
              </ItemTemplate>
              </asp:TemplateField>
          </Columns>


      </asp:GridView>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900