Click here to Skip to main content
15,914,160 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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...?
Posted

1 solution

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.


C#
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;
            }

        }



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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900