如何动态生成TextBox。 [英] How can I generate TextBox dynamically.

查看:76
本文介绍了如何动态生成TextBox。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个网页,允许员工根据滚动号码输入学生的标记。我创建了一个页面,工作人员必须输入主题代码(比如std3sec1),这些主题代码对所有员工都是唯一的。因此,当工作人员输入主题代码时,必须将所有已根据该主题代码注册的学生拉出来,并且工作人员将能够为所有这些学生输入分数。为了更好地理解,我将尝试给下面的图片代表

数据库:

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:

rollnum | Name   | SubjectCode
001	  ABC	   std3sec1
002	  BCD	   std3sec1
003	  HBC	   std3sec2
004	  NCD	   std3sec2



因此,当员工输入主题代码为std3sec1时,以下详细信息必须显示在下一个webform中。


So when the staff enter subject code as std3sec1, the following details has to display in next webform.

name | rollnum | test1 	   | test2 	| Quiz
ABC	001	 staff_ip    staff_ip    staff_ip
BCD	002	 staff_ip    staff_ip    staff_ip





这里,staff_ip代表员工必须输入的标记。

我的主要问题是如何动态生成文本框让员工根据从数据库中提取的数据输入他们的学生考试成绩?如果Textboxes真的很糟糕,那么我该怎么做才能克服文本框。或者有什么方法可以使用表格来输入标记吗?

谢谢。



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.

推荐答案

使用gridview1或gridview2



Use Either gridview1 or gridview2

<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>

这篇关于如何动态生成TextBox。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆