如何使用Activex创建Gridview [英] How to create Gridview using Activex

查看:71
本文介绍了如何使用Activex创建Gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建Gridview以便从用户那里获取输入.它具有下拉列,文本框
列和复选框列.我们可以在运行时添加行.如何使用Activex创建它

请帮助我

I want to create Gridview for get input from user. It has Dropdown Column, Textbox
Column and Checkbox Column. We can add rows at runtime. How to create it using Activex

Please help me

推荐答案

请参考以下主题:

要添加下拉列,文本框列和复选框列:
在GridView控件中使用TemplateFields [带有文本框,复选框,单选按钮和下拉列表的可编辑Gridview [ ^ ]

要添加运行时行:
试试这个:

Please refer following threads:

To add Dropdown Column, Textbox Column and Checkbox Column:
Using TemplateFields in the GridView Control[^]
Editable Gridview with Textbox, CheckBox, Radio Button and DropDown List[^]

To add rows runtime:
Try this:

//declaring a datatable global in form 
DataTable dtglb=new DataTable();

//In click event    
SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;Initial Catalog=EMS;User ID=sa;Password=sa123");

string SQL1 = "SELECT coursename,coursefees,batchname FROM  CourseMaster,BatchMaster WHERE CourseMaster.coursemasterid=BatchMaster.coursemasterid and CourseMaster.coursemasterid="+coursemasterid+" and BatchMaster.batchmasterid="+batchmasterid+"";
    SqlCommand cmd = new SqlCommand(SQL1, con);
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    DataTable ds = new DataTable();
    //DataColumn faculty = new DataColumn();
    da.Fill(ds);
    GridView1.DataSourceID = null;

    //New Code Added Here
    DataRow row = ds.NewRow();
    //your columns
    row["columnOne"] = valueofone;
    row["columnTwo"] = valueoftwo;
    dtglb.Rows.Add(row);
        foreach(DataRow dr in dtglb.Rows)
    {
     ds.Rows.Add(dr);
    }
    //=========
    GridView1.DataSource = ds;
    GridView1.DataBind(); 


也可以在此处查看一下 [


also have a look here[^]


为什么需要ActiveX在运行时在网格中添加行?

您已准备好在GridView中具有添加行功能.看这里:
GridView一目了然 [在GridView中就地编辑 [
Why do you need an activeX to add rows in grid at runtime?

You have provision to have add row feature in GridView. Look here:
GridView all in one[^]
Inplace Edit in GridView[^]


这篇关于如何使用Activex创建Gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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