Help EditItemTemplate datagrid

Discussion in 'ASP .Net Datagrid Control' started by SStory, Apr 19, 2004.

  1. SStory

    SStory Guest

    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
     
    SStory, Apr 19, 2004
    #1
    1. Advertising

  2. SStory

    anon Guest

    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


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    anon, Apr 20, 2004
    #2
    1. Advertising

  3. SStory

    SStory Guest

    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

    "anon" <> wrote in message
    news:...
    > 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
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    SStory, Apr 24, 2004
    #3
  4. SStory

    SStory Guest

    nevermind the previouis

    I found the solution

    Thanks,.
    "anon" <> wrote in message
    news:...
    > 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
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    SStory, Apr 24, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Trevor Hartman

    datagrid edititemtemplate for dates

    Trevor Hartman, Jul 16, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    374
    Trevor Hartman
    Jul 16, 2003
  2. Dave
    Replies:
    1
    Views:
    543
  3. Gene McCrory
    Replies:
    5
    Views:
    4,159
    Yan-Hong Huang[MSFT]
    Dec 12, 2003
  4. =?Utf-8?B?bWc=?=
    Replies:
    1
    Views:
    658
    Ashish M Bhonkiya
    May 18, 2004
  5. Replies:
    1
    Views:
    508
    Teemu Keiski
    Jun 22, 2005
Loading...

Share This Page