从gridivew拆分并显示在列表框中 [英] Split and display in listbox from gridivew

查看:52
本文介绍了从gridivew拆分并显示在列表框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个GridView

我有一个标题namned工具

有工具显示t1,t2,t3这样

时按编辑按钮我想在列表框中显示

喜欢这个

t1

t2

t3

现在它只在一行显示值

像这样t1,t2,t3

I have a GridView
Where i have a header namned Tools
There Tools gets displayed t1,t2,t3 like that
when pressing edit button i want to display that in a listbox
like this
t1
t2
t3
right now it displayes the values on only one line
like this t1,t2,t3

 protected void GridViewShowAssignments_RowEditing(object sender, GridViewEditEventArgs e)
        {
            GridViewRow row = GridViewShowAssignments.Rows[e.NewEditIndex];

            TextBoxCompanyName.Text = ((Label)row.FindControl("LabelAssignmentCompanyName")).Text;
            TextBoxSector.Text = ((Label)row.FindControl("LabelAssignmentSector")).Text;
            TextBoxArea.Text = ((Label)row.FindControl("LabelAssignmentArea")).Text;
            TextBoxFromDate.Text = ((Label)row.FindControl("LabelAssignmentFromDate")).Text;
            TextBoxToDate.Text = ((Label)row.FindControl("LabelAssignmentToDate")).Text;
            TextBoxDesc.Text = ((Label)row.FindControl("LabelAssignmentDescription")).Text;
            TextBoxReference.Text = ((Label)row.FindControl("LabelAssignmentReference")).Text;

// here is the code that i dont get to work
            
                foreach (GridViewRow row1 in GridViewShowAssignments.Rows)
                {
                    ListBoxAssignmentTools.Items.Add(((Label)row1.FindControl("LabelAssignmentTool")).Text + Environment.NewLine.Split(','));


                    ListBoxAssignmentTechnology.Items.Add(((Label)row1.FindControl("LabelAssignmentTechnology")).Text + Environment.NewLine.Split(','));
                
                }

推荐答案

试试这个...

Try this...
ListBoxAssignmentTools.Items.AddRange(((Label)row1.FindControl("LabelAssignmentTool")).Text.Split(','));



快乐编码!

:)


Happy Coding!
:)






在gridview中使用编辑模板。



在编辑模板的地方列表视图中,将结果与列表视图绑定。



查看此链接以获取编辑模板:



http://www.asp.net/web-forms/tutorials/data-access/custom-formatting/using-templatefields-in -the-gridview-control-cs [ ^ ]


这篇关于从gridivew拆分并显示在列表框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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