?
Solved

Asp.net datagrid edit column

Posted on 2008-06-15
2
Medium Priority
?
1,973 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
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…

771 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