Solved

Asp.net datagrid edit column

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
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…

911 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

18 Experts available now in Live!

Get 1:1 Help Now