|
-
Nov 26th, 2002, 11:40 AM
#1
Thread Starter
Addicted Member
Datagrid textbox width (edit mode)***resolved****
I have a datagrid that has Edit, Update,Cancel capability (the custom column). What I need is to specify the width of the textbox when I choose edit. As it stands the grid triples in size because of the size of the input fields. I tried the following code
VB Code:
Public Sub DataGrid_Edit(ByVal Source As Object, ByVal E As DataGridCommandEventArgs)
dgBeach.EditItemIndex = E.Item.ItemIndex
BindData()
E.Item.Cells(3).Width = System.Web.UI.WebControls.Unit.Pixel(25)
End Sub
I also tried with the pixel code in different spots but no difference can be seen.
Any ideas?
Last edited by Halon; Nov 26th, 2002 at 06:08 PM.
Soylent Green tastes like chicken
-
Nov 26th, 2002, 03:21 PM
#2
Try e.Item.Attributes.Add("Style", "Width: 25px;")
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Nov 26th, 2002, 03:43 PM
#3
Thread Starter
Addicted Member
Nope ... can't figure out exactly where it is creating these default text boxes when you click on edit. Do I have to make each column a template column maybe?
Soylent Green tastes like chicken
-
Nov 26th, 2002, 06:07 PM
#4
Thread Starter
Addicted Member
OK I ended up going with template columns
In my datagrid update code
VB Code:
Dim Cash As Integer
Cash = CType(E.Item.FindControl("txtcash"), TextBox).Text
In the html for the datagrid
VB Code:
<asp:TemplateColumn HeaderText="Cash">
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval Container, "DataItem.Cash", "{0:$#,###.##}") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" id="txtcash" columns="3" Text='<%# DataBinder.Eval(Container, "DataItem.Cash") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
It now allowed me to set the column width for the textbox
yeehaww i guess
Soylent Green tastes like chicken
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|