将列添加到DataSet [英] Adding columns to DataSet

查看:64
本文介绍了将列添加到DataSet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在收集用户的一组信息,它们是:name,rollnum,fathername,dept,branch,Sem和gender。当用户输入此信息并单击按钮SubCode时,必须根据用户从我写入查询的其他表中输入的Dept,Branch和Sem获取SubTitle,并且它工作正常。

表的定义(TblSub)

I am gathering a set of information from users and they are : name,rollnum,fathername,dept,branch,Sem and gender. When user enters this information and click button SubCode, SubTitle has to be fetched based of Dept,Branch and Sem entered by the user from the other table for which I have written a Query and it is working fine.
Defination of table (TblSub)

SubCode   |SubTitle         |Dept              |Branch           |Sem
C1        C Programming      Computer Science  Computer Science   1
J1        Java Programming   Computer Science  Computer Science   1
J1        C++ Programming    Computer Science  Computer Science   2



现在我的主要问题是我要显示(rollnum,Name,Fathername,SubCode ,GridTit中的,SubTitle)。

当用户选择dept = branch =计算机科学和sem = 1


Now my main problem is I want to display (rollnum,Name,Fathername,SubCode,SubTitle) in a gridview.
Output of the gridview has to look like this when user select dept=branch=Computer Science and sem = 1

rollnum     |Name    |Fathername   |SubCode   |SubTitle 
01           stud1    father1        C1        C Programming
01           stud1    father1        J1        Java Programming



每个学生的子代码数量因人而异他们选择的部门,分支和sem。我将使用数据集,我将首先输入rollnum,name,fathername,然后添加列子代码和字幕列。但由于每个学生的子代码数量不同,我没有得到如何实现这一点。我很高兴知道除了数据集之外是否有任何其他方式更方便使用。请帮忙。谢谢。


The number of subcode differs to each student based on the dept,branch and sem they select. I tot of using dataset where I will 1st enter rollnum,name,fathername and then add column subcode and subtitle column wise. But as the number of subcode differs for each student I not getting how to achieve this. I will be glad to know if there is any other way other then dataset which is more convenient in using. Please help. Thank you.

推荐答案

static DataSet ds_input = new DataSet();
static DataSet ds_output = new DataSet();

private static void InitializeMyDataSet()
{
    ds_output.Tables.Add(new DataTable() );
    ds_output.Tables[0].Columns.Add("column_1", typeof(string));
    ds_output.Tables[0].Columns.Add("column_2", typeof(string));
    ds_output.Tables[0].Columns.Add("column_4", typeof(string));
    ds_output.Tables[0].Columns.Add("column_3", typeof(string));
}


这篇关于将列添加到DataSet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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