| |

VerySource

 Forgot password?
 Register
Search
View: 603|Reply: 2

Modify the data in Datagrid. When I click the edit button, the data appears in the text box. How can I control the size

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-10 22:00:01
| Show all posts |Read mode
My method doesn't seem to work!
Everyone help me !!

private void dgLevel_ItemDataBound (object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{

for (int i = 0; i <e.Item.Cells.Count-1; i ++)
{
if (e.Item.ItemType == ListItemType.EditItem)
{
e.Item.Cells [i] .Attributes.Add ("Width", "40px");
}
}
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-6-5 17:00:02
| Show all posts
TextBox txt=(TextBox)e.Item.Cells[i].findControls("text box name");
if(txt != null){ txt.Width=Width;}
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-6-6 18:00:02
| Show all posts
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.EditItem)
{
((TextBox)e.Item.Cells[2].Controls[0]).Width = Unit.Parse("80");
}
}
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list