Professional Web Applications Themes

DataGrid Edit TextBox - ASP.NET Data Grid Control

Hi NG. I'm having trouble controling the size of the textboxes that appear when the user clicks the "edit" button for a row in my datagrid. I know it can be done and I know it doesn't require much, but I just can't seem to find out how to anyway. If anyone could help me out with this little problem it would be much appreciated :) Thanks /Aidal...

  1. #1

    Default DataGrid Edit TextBox

    Hi NG.

    I'm having trouble controling the size of the textboxes that appear when the
    user clicks the "edit" button for a row in my datagrid.
    I know it can be done and I know it doesn't require much, but I just can't
    seem to find out how to anyway.

    If anyone could help me out with this little problem it would be much
    appreciated :)

    Thanks
    /Aidal


    Aidal Guest

  2. #2

    Default Re: DataGrid Edit TextBox

    We'll help you, but what is the problem? All I got was that you wanted to control the size of the textboxes, but you'll need to be more specific than that.



    --------------------------------------------------------------------------------
    All that glitters has a high refractive index.
    [url]www.mendhak.com[/url]
    "Aidal" <aidatheonlyhotmail.com> wrote in message news:dkd5rn$jt1$1pomoranche.gu.net...
    Hi NG.

    I'm having trouble controling the size of the textboxes that appear when the
    user clicks the "edit" button for a row in my datagrid.
    I know it can be done and I know it doesn't require much, but I just can't
    seem to find out how to anyway.

    If anyone could help me out with this little problem it would be much
    appreciated :)

    Thanks
    /Aidal


    S.M. Altaf [MVP] Guest

  3. #3

    Default Re: DataGrid Edit TextBox

    Umm..Hmm that's it more or less - I'm not sure what else there is to
    explain about it.

    I want to be able to control the size of the textboxes that appear when
    I click an 'Edit' button for a line in my datagrid.

    Currently they are too long (the default width) resulting in the
    datagrid becoming wider when a row is in edit mode and that doesn't look
    good.

    So I wan't to make sure that the width of the grid doesn't change once
    an 'edit' button is clicked.

    So that if this [----this width----] was the original size of a textbox
    when a row is in edit mode, the new version could be [-this width-].

    I hope this helps clearify what it is I mean.

    /Aidal



    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Aidal Theonly Guest

  4. #4

    Default Re: DataGrid Edit TextBox

    Hi, Aidal, you have two ways to do it. If you are using the BoundColumn, then
    you can set the width of textbox in the ItemCreated event.

    protected void dgrd_ItemCreated(Object sender, DataGridItemEventArgs e)
    {
    if(e.Item.ItemType == ListItemType.EditItem)
    {
    TextBox txt = (TextBox)e.Item.Cells[X].Controls[0];
    txt.Width = < the width you want it to be>;
    }
    }

    Another way is set the TextBox's width declaractively in the TemplateColumn.


    Hope this helps....
    alvinz_c Guest

Similar Threads

  1. Replies: 8
    Last Post: April 29th, 09:33 AM
  2. Set the width of the edit textbox after clicking on Edit link in datagrid...
    By Sharon McCarty in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: November 24th, 06:41 PM
  3. Textbox Font and Fontsize in Edit Mode
    By RockNRoll in forum ASP.NET Data Grid Control
    Replies: 1
    Last Post: September 1st, 06:34 AM
  4. DataGrid ItemStyle is a textbox and doesn't update the datagrid datasource
    By matthew schouppe in forum ASP.NET Data Grid Control
    Replies: 3
    Last Post: April 30th, 03:02 PM
  5. Edit Datagrid - show textbox and dropdown
    By Anamika in forum ASP.NET Data Grid Control
    Replies: 2
    Last Post: April 20th, 10:33 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139