Solved

Asp.net datagrid edit column

Posted on 2008-06-15
2
1,949 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Android studio getdrawable(int) is deprecated 4 82
Angular JS Route 3 68
VB 2005 Tooltips on Form Load Event 15 29
Regex validation 2 24
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

813 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

13 Experts available now in Live!

Get 1:1 Help Now