Windows应用程序中的Gridview问题 [英] Gridview problem In windows application

查看:69
本文介绍了Windows应用程序中的Gridview问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在gridview中,我有2列,其中1列是Question(问题),第2列是Answer(答案).

在第一列中,我正在显示问题.但是在第二列中,我限制了组合框.我的问题是


在第二列中,每个组合框都有不同的选项.这样的事情.

column1第2列
工作状态(好,平均和差)是什么?
您是否有兴趣工作(是,不是)

我该如何实现.任何建议都感谢我

预先感谢

Hi,

In gridview I have 2 columns, 1 is Question and 2nd one is answer.

In the first column I am displaying question. But in the 2nd column I bounded combo box. My problem is


In the second column each and every combo box may vary with different options. some thing like this.

column1 Column 2
What is the work Status (Good,Average and Poor)
Are you interested to work (Yes,No)

how can I achieve it. any suggestions are grateful to me

Thanks in advance

推荐答案

基于行,您可以在RowDataBound列中进行一些操作,以设置适当的数据源,然后设置DataValueField DataTextField 属性.
Based on the row, you can do some manipulations in the RowDataBound column to set the appropriate datasource and then DataValueField and DataTextField properties.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow &&
    (e.Row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit)
    {
        DropDownList dl = (DropDownList)e.Row.FindControl("DropDownList1");

        dl.DataSource = dt;
        dl.DataValueField = "Status";
        dl.DataTextField = "Status";
        dl.DataBind();
    }
}


这篇关于Windows应用程序中的Gridview问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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