Current location: Hot Scripts Forums » Programming Languages » ASP.NET » TextBox-width in DataGrid-Editing Mode


TextBox-width in DataGrid-Editing Mode

Reply
  #1 (permalink)  
Old 04-07-06, 02:24 PM
bastler72 bastler72 is offline
Newbie Coder
 
Join Date: Apr 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
TextBox-width in DataGrid-Editing Mode

alo,
I build a DataGrid, with an Editing-column (like is written in msdn-library and others). Well, I would like to change the size/width from the TextBoxes, which you can see if you click on the Edit-Button. These TextBoxes are to large, larger than the normal size of the columns - that seems not nice.

Has anybody a solution how to change the size from that? (Maybe if possible also to change the size from the Buttons Edit, Cancel and Update)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 04-08-06, 08:20 PM
koncept
Guest
 
Posts: n/a
you can use css classes or depending upon your code specify it the textbox and button code
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 04-29-06, 08:45 AM
bastler72 bastler72 is offline
Newbie Coder
 
Join Date: Apr 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
alo,
first have thx for your answer.

the problem with the textbox-field is, that's a textbox witch is created in the datagrid, if you create a editable-column...that's not a textbox separate!! so you dont cannot change some properties easily in the vb-code. i tried to use css-class (was also shown in the html-code), but this doesnt work, dont know why. I have got a css class from the grid by itself already, dont know really how to program a separate css für this textbox!!...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 04-29-06, 11:02 AM
koncept
Guest
 
Posts: n/a
can you post your code, the textbox width can be set if you are using the <edittemplatecolum>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 05-04-06, 03:04 AM
bastler72 bastler72 is offline
Newbie Coder
 
Join Date: Apr 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Post

hi,
ok, here is the code from this used datagrid with the edit-column. I dont use the template-column, just the edit-command-column. Can be this the problem? have you got an idea for that. I also tried some possibilities with css, but nothing could help.

here the code:

<DIV style="OVERFLOW: auto; WIDTH: 550px; HEIGHT: 420px" noWrap>
<asp:datagrid id="DataGrid1" runat="server" OnUpdateCommand="DataGrid1_Update" OnCancelCommand="DataGrid1_Cancel"
OnItemCommand="DataGrid1_ItemCommand"
onEditCommand="DataGrid1_Edit"
OnPageIndexChanged="DataGrid1_Page"
OnItemCreated="DataGrid1_ItemCreated"
CssClass="RXO_Product_DataGrid" ItemStyle-CssClass="RXO_DataGrid_ItemStyle"
HeaderStyle-CssClass="RXO_DataGrid_HeaderStyle" >
<Columns>
<asp:EditCommandColumn ButtonType="PushButton"
UpdateText="Update" CancelText="Cancel" EditText="Edit"
ItemStyle-CssClass="RXO_DataGrid_EditField" >
</asp:EditCommandColumn>
</Columns>
</asp:datagrid>
</DIV>

pls note, there is no code for the edit-column for the textbox, just for the handling with edit, cancel, update-button!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 05-04-06, 02:20 PM
koncept
Guest
 
Posts: n/a
please take a look at both part 6 and 7
http://aspnet.4guysfromrolla.com/articles/071002-1.aspx

they explain just about everything you can do with datagrid editing. Specificaly in part 7, instead of using the dropdown list you can use a text box and specify the width there
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 02-19-07, 08:11 PM
Mikeirv Mikeirv is offline
Newbie Coder
 
Join Date: May 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Just edit the template column in vs and click and drag on the handles to make it smaller.

Can't get any easier.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 04-15-09, 04:17 PM
mmgoldstein mmgoldstein is offline
New Member
 
Join Date: Apr 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Dynamic way to format Datagrid TextBoxes

In some cases, folks like to dynamically populate their DataGrids and have the columns autogenerate. I do this most of the time, and also had the need to adjust column width. I've seen ONE post so far in all my searching that mentioned how to do it in code, but it did not work. Below, you will see a simple function that I wrote in C# to address the issue of customizing datagrid child controls.

Right now, this can be used for textboxes, but as I'm sure you can see, expanding it would be pretty darn easy to encompass other child controls.

Feel free to use this code as is or modify to do what you want it to. Here is the sample code also, to use the function....

Example Call Statement:
Code:
AdjustDataGridTextBoxWidth(<Name of DataGrid Here>, "TextBox", 110, 4, TextBoxMode.MultiLine, 8);

The Function Code:
    private void AdjustDataGridTextBoxWidth(DataGrid GridName, string SubControlType, Unit Width, int RowsCount, TextBoxMode TBMode, FontUnit FontSize)
    {
        if (SubControlType == "TextBox")
        {
            for (int i = 0; i < GridName.Items.Count; i++)
            {
                for (int o = 1; o < GridName.Items[i].Cells.Count; o++)
                {
                    for (int x = 0; x < GridName.Items[i].Cells[o].Controls.Count; x++)
                    {
                        if (GridName.Items[i].Cells[o].Controls[x].GetType().ToString() == "System.Web.UI.WebControls.TextBox")
                        {
                            TextBox GridTextBox = (TextBox)GridName.Items[i].Cells[o].Controls[x];
                            GridTextBox.Width = Width;
                            GridTextBox.Rows = RowsCount;
                            GridTextBox.TextMode = TBMode;
                            GridTextBox.Font.Size = FontSize;
                        }
                    }
                }
            }
        }
    }

Last edited by Nico; 04-17-09 at 12:12 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 12:42 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.