Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid Edit Mode width 1

Status
Not open for further replies.

aaronjonmartin

Technical User
Jul 9, 2002
475
0
0
GB
Hi guys hope someone can shed some light on this problem. I have a datagrid on a css positioned page. And in normal mode (i.e. displaying data) it fits on the page nicely. However when i click the edit button it breaks the page width and extends off the right hand side of the screen.

How can i prevent this from happening, i.e. how can i get the datagrid to stay the same width in edit mode? And if the content in the columns to be edited is too long to be displayed the field displaying it extends down instead of horizontally?

Below is the code for my datagrid

Code:
<asp:DataGrid id="WorkHistDG"
	BorderWidth="1"
	BorderColor="#C1DAD7"
	CellPadding="3"
	CellSpacing="0"
	HorizontalAlign="Center"
	Font-Name="Verdana"
	Font-Size="12px"
	HeaderStyle-BackColor="#54A2CF"
	ItemStyle-BackColor="#EEF7FB"
	AutoGenerateColumns="false"
	AllowPaging="True"
	OnPageIndexChanged="OurPager"
	PageSize="5"
	PagerStyle-NextPageText="Next 5 >"
	PagerStyle-PrevPageText="< Prev 5"
	PagerStyle-HorizontalAlign="Left"
	OnEditCommand="Edit"
	OnCancelCommand="Cancel"
	OnUpdateCommand="Update"
	DataKeyField="WorkID" 
	OnDeleteCommand="DeleteRow" 
	OnItemDataBound="ConfirmDelete"
	runat="server">
	<AlternatingItemStyle backcolor="#C7E0EF"></AlternatingItemStyle>
		<columns>
			<asp:boundcolumn Headertext="WorkID" DataField="WorkID" readonly="true" visible="False"/>
			<asp:boundcolumn Headertext="Start Date" DataField="WorkStart" DataFormatString="{0:d}"/>
    			<asp:boundcolumn Headertext="End Date" DataField="WorkEnd" DataFormatString="{0:d}"/>
			<asp:boundcolumn Headertext="Organisation" DataField="WorkCompany"/>
			<asp:boundcolumn Headertext="Job Title" DataField="WorkJobTitle"/>
			<asp:boundcolumn Headertext="Work Nature" DataField="WorkNature"/>
			<asp:boundcolumn Headertext="Location" DataField="WorkLocation"/>
			<asp:boundcolumn Headertext="Duties" DataField="WorkDuties"/>
			<asp:boundcolumn Headertext="Reason for Leaving" DataField="WorkLeaving"/>
			<asp:EditCommandColumn
				ButtonType="PushButton"
				EditText="Edit"
				CancelText="Cancel"
				UpdateText="Update"/>
			<asp:ButtonColumn ButtonType="PushButton" Text="Delete" CommandName="Delete"/>
		</columns>
</asp:DataGrid>

&quot;It's so much easier to suggest solutions when you don't know too much about the problem.&quot;
Malcolm Forbes (1919 - 1990)
 
Try having a look at the EditItemTemplate tag


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks for the reply mate, i am just looking into EditItemTemplate now. Will I still be able to use boundcolumns or would i have to change them to ItemTemplate too?

&quot;It's so much easier to suggest solutions when you don't know too much about the problem.&quot;
Malcolm Forbes (1919 - 1990)
 
You can still use boundcolumns if you wish


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Is there no way i can just restrict the size of the datagrid in edit mode using css?

&quot;It's so much easier to suggest solutions when you don't know too much about the problem.&quot;
Malcolm Forbes (1919 - 1990)
 
You can restrict the size of the datagrid in terms of the size of the div that it is created in, but each textbox that is generated will still have a certain width attached to it (so really you should change it in the EditItemTemplate - you can do so by assigning it cssClass).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Ok I got it working with EditItemTemplate (thankyou for the suggestion) so basically i have made all the text boxes smaller. However what I would really want to do is, say i have a textbox which has a fair bit of text in it is there anyway i could have it restricted in width but multiple lines displayed? Like a textarea in html. Does that make sense?

&quot;It's so much easier to suggest solutions when you don't know too much about the problem.&quot;
Malcolm Forbes (1919 - 1990)
 
You can set the TextMode of a TextBox to MultiLine and it will render a textarea.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thankyou for the help.

Shame there is no way to constrain the size of the datagrid in edit mode like you can in normal mode by just setting the width property

&quot;It's so much easier to suggest solutions when you don't know too much about the problem.&quot;
Malcolm Forbes (1919 - 1990)
 
Hey, I'm having the same problem. Can you explain the syntax for using the EditItemTemplate with BoundColumns as opposed to TemplateColumns? Thanks in advance!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top