Solved

Asp.net datagrid edit column

Posted on 2008-06-15
2
1,943 Views
Last Modified: 2013-11-07
      

When i click on edit,i am getting textboxes in grid to edit data.But their width is more and the grid is expanding .Is there a way to restrict the size of  editable text boxes.
<asp:DataGrid ID="gridLenders" runat="server" DataKeyField="id" BorderStyle="Ridge" GridLines="None" BorderWidth="2px" BorderColor="White" BackColor="White" CellPadding= "3" CellSpacing="1" AllowSorting="True" 

			  PagerStyle-HorizontalAlign = "Center" HorizontalAlign="Left" OnEditCommand="gridLenders_EditCommand" OnCancelCommand= "gridLenders_CancelCommand"  OnUpdateCommand="gridLenders_UpdateCommand"

			    OnDeleteCommand= "gridLenders_DeleteCommand" AutoGenerateColumns="false" width="96%" >
 

          
 

        <FooterStyle ForeColor="Black" BackColor="#C6C3C6"></FooterStyle>
 

        <HeaderStyle Font-Bold="True" ForeColor="#FFFFFF" 
 

                  BackColor="#A53A6A"></HeaderStyle>
 

       <FooterStyle BackColor="beige" />

       <Columns>
 

        <asp:BoundColumn DataField="Id" HeaderText="ID"  Visible ="false" >
 

          <ItemStyle BackColor="graytext" />
 

          <HeaderStyle BackColor="graytext" />
 

          </asp:BoundColumn>
 

         
 

          <asp:BoundColumn DataField="Lender" HeaderText="Lender">
 

          <ItemStyle BackColor="GhostWhite" />
 

          </asp:BoundColumn>
 

                  
 

          <asp:BoundColumn DataField="AccreditationId" HeaderText="AccreditationId">
 

          <ItemStyle BackColor="GhostWhite" />
 

          </asp:BoundColumn>
 

        

          <asp:EditCommandColumn CancelText="Cancel" EditText="Edit"  
 

                         UpdateText="Update" HeaderText="Modify">
 

          <ItemStyle BackColor="GhostWhite" />
 

          </asp:EditCommandColumn>

 <asp:ButtonColumn CommandName="Delete" HeaderText="Delete" Text="Delete">
 

          <ItemStyle BackColor="GhostWhite" />
 

          </asp:ButtonColumn>

 </Columns>
 

   </asp:DataGrid>

Open in new window

0
Comment
Question by:lakshmidurga
2 Comments
 
LVL 8

Expert Comment

by:theplonk
ID: 21791220
Try setting the bound column control style width for the column either through the designer or via code:

<asp:BoundColumn DataField="Id" HeaderText="ID"  Visible ="false" >
     <ControlStyle Width="100px" />
     <ItemStyle Width="100px" BackColor="graytext" />
     <HeaderStyle BackColor="graytext" />
</asp:BoundColumn>
0
 
LVL 7

Accepted Solution

by:
lakshmidurga earned 0 total points
ID: 21809122
Protected Sub Item_Created(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
    If e.Item.ItemType = ListItemType.EditItem Then

        Dim EditDescription As TextBox = CType(e.Item.Cells(0).Controls(0), TextBox)
        EditDescription.Width = Unit.Parse("500px")

    End If

End Sub

This is the solution
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org (http://seleniumhq.org) Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now