首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >是否将文本框放入excel单元格?

是否将文本框放入excel单元格?
EN

Stack Overflow用户
提问于 2013-09-25 21:12:29
回答 1查看 342关注 0票数 0

我正在尝试在行数据绑定中适合ASP.NET gridView中的文本框。在这里,它没有在cell.to中进行适当的调整以适合它。

在行数据绑定中,我使用

代码语言:javascript
运行
复制
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onclick", "this.style.backgroundColor='orange'");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='white'");
            e.Row.Cells[2].Width = new Unit("700px");
            TextBox txtAddress = new TextBox();
            txtAddress.ReadOnly = false;
            e.Row.Cells[2].Controls.Add(txtAddress);
            e.Row.Cells[2].Style.Add("text-align", "center");
            txtAddress.Text = e.Row.Cells[2].Text;
            GridView1.Attributes.Add("style", "table-layout:fixed");
        }
    }

如何在网格单元格中适当地拟合它。

EN

回答 1

Stack Overflow用户

发布于 2013-09-26 00:30:37

我正在试这个,它工作得很好..

代码语言:javascript
运行
复制
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onclick", "this.style.backgroundColor='orange'");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='white'");
                e.Row.Cells[2].Width = new Unit("700px");
                TextBox txtAddress = new TextBox();
                txtAddress.ReadOnly = false;
                //txtAddress.Style = "width:100%;";
                txtAddress.Style.Add("width", "99%");
                e.Row.Cells[2].Controls.Add(txtAddress);
                e.Row.Cells[2].Style.Add("text-align", "center");
                txtAddress.Text = e.Row.Cells[2].Text;
                GridView1.Attributes.Add("style", "table-layout:fixed");
            }
        }

100%在数学上是准确的,但99为我做了这个把戏:)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19005925

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档