Help EditItemTemplate datagrid

S

SStory

I need help.

I have a datagrid bound to a dataset produced in code
this time I want to put in edit mode

I have that woring but can't format the edit mode stuff

tried EditItemtemplate as follows.

<asp:datagrid id="grdCommentsOnRep" runat="server"
CssClass="smallblacktext" Width="100%" AllowPaging="True"
AutoGenerateColumns="False" DataKeyField="CorRep_ID">
<AlternatingItemStyle
BackColor="Lavender"></AlternatingItemStyle>
<ItemStyle ForeColor="Black" BackColor="White"></ItemStyle>
<HeaderStyle ForeColor="White" BackColor="Purple"></HeaderStyle>
<Columns>
<asp:EditCommandColumn ButtonType="LinkButton"
UpdateText="Update" CancelText="Cancel" EditText="Edit">
<HeaderStyle Width="10px"></HeaderStyle>
</asp:EditCommandColumn>
<asp:ButtonColumn Text="Delete" CommandName="Delete">
<HeaderStyle Width="10px"></HeaderStyle>
</asp:ButtonColumn>
<asp:BoundColumn DataField="corDate" ReadOnly="True"
HeaderText="Date">
<HeaderStyle Width="15px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="corCommentType" ReadOnly="True"
HeaderText="Type">
<HeaderStyle Width="10px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="corJob_ID" ReadOnly="True"
HeaderText="Job ID">
<HeaderStyle Width="10px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="corComment" HeaderText="Comment"
ItemStyle-Wrap="True" ItemStyle-Width="50%">
<HeaderStyle Width="300 px"></HeaderStyle>
</asp:BoundColumn>
<asp:TemplateColumn>
<EditItemTemplate>
<asp:Label text='<%# DataBinder.Eval(Container.DataItem,
"corDate") %>'>
</asp:Label>
<asp:Label text='<%# DataBinder.Eval(Container.DataItem,
"corCommentType") %>'>
</asp:Label>
<asp:Label text='<%# DataBinder.Eval(Container.DataItem,
"corJob_ID") %>'>
</asp:Label>
<asp:TextBox Rows=4 Width=300px text='<%#
DataBinder.Eval(Container.DataItem, "corComment") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle ForeColor="White" Position="TopAndBottom"
BackColor="Purple" Mode="NumericPages"></PagerStyle>
</asp:datagrid>

I want the edit mode for the comment to have like a text area 4 rows tall
and half the width of the screen or say 300pix.
what am I doing wrong?

thanks,

Shane
 
A

anon

if i understand correctly, u would like a particular column of dg to
have a textarea of height x...
u need to specify that on the pre render event of the datagrid like
this....

public void dg_PreRender(object sender, System.EventArgs e)

{
if (dg.EditItemIndex!= -1 )
{
TextBox aTextBox = new TextBox();
aTextBox =
(TextBox)(dg.Items[dg.EditItemIndex].Cells[8].Controls[0]);
aTextBox.Width=Unit.Parse("5cm");
aTextBox.Height=Unit.Parse("2cm");
//aTextBox.Wrap=true; //aTextBox.TextMode=TextBoxMode.MultiLine;
}
}

HTH,
Ben
 
S

SStory

Thanks anon,

Got that working but now

in updatecommand
findcontrol will not find txtEditComment
which is in my edititemtemplate

Bummer.

thanks for the reply.

Shane
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top