有关GridView修改的问题吗? [英] Question about GridView modification?

查看:61
本文介绍了有关GridView修改的问题吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网格视图中使用TextBox.Text.
我想在不同的行中以不同的宽度"使用它.
请帮我怎么可能...?

i''m using TextBox.Text inside the grid view.
i wana use it with different ''width'' in the different Rows.
Kindly help me how it is possible...?

推荐答案

您好,成员8911636,

您只需要向GridView的RowDataBound事件添加一些代码.

在运行时创建一个文本框,并将其添加到Gridview单元中.
例如,我采用一个以35初始化的整数,该整数在创建每个文本框后递增,只是向您展示它的工作原理.试试看.


Hi Member 8911636,

You just need to add some code to RowDataBound event of the GridView.

Create a text box on runtime and add this in Gridview cell.
For example, I''ve taken an integer initialized with a value 35, which increments after every text box created, just to show you that it works. Give it a try.


static int count = 35;
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                TextBox txt = new TextBox();
                txt.ID = "txt" + e.Row.RowIndex.ToString();
                txt.Width = new Unit(count);
                e.Row.Cells[2].Controls.Add(txt);
                count += 15;
            }

        }




并且我建议您至少在个人资料中填写好名字.这确实有助于我们个性化一个我们从未见过的家伙....只是一个建议.

希望对您有帮助.

快乐编码:)

Sunny K




and also I would suggest you to at least fill your good name in your profile. It really helps us to personalize a guy who we never been to see....just a suggestion.

Hope this helps you.

Happy Coding :)

Sunny K


这篇关于有关GridView修改的问题吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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