Click here to Skip to main content
13,298,551 members (39,020 online)
Rate this:
Please Sign up or sign in to vote.
See more:
hello frens, i have this small problem in

i have a code like this...

<asp:DataList ID="DataList1" runat="server" >

              <asp:Label ID="Label2" runat="server" Text='<%#Eval("status") %>'></asp:Label>
              <br />    <hr />
              <asp:DataList ID="DataList2" runat="server" DataSource='<%#getCommentsByStatID(Eval("statid").ToString()) %>'>
                      <asp:Label ID="Label1" runat="server" Text='<%#Eval("comment") %>'></asp:Label>
              <asp:TextBox ID="txtcomment" runat="server" Text='<%# Container.DataItem %>' ></asp:TextBox>
              <asp:Button ID="btncomment" runat="server" Text="Post" PostBackUrl='<%# "~/Default2.aspx?statusid="+Eval("statid")%>' />
          <SeparatorTemplate><hr /></SeparatorTemplate>


when the button btncomment is clicked, i need to get the text of txtcomment saved in the database by knowing the status id.. i can get the status id from the query string but i cannot get the text of txtcomment ..

please help with some suitable codes or links .........

with thanks
Posted 1-Jan-13 6:47am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Add ItemCommand Event on your datalist as given below.

<asp:datalist id="DataList1" runat="server" onitemcommand="DataList1_ItemCommand" xmlns:asp="#unknown">
                <asp:textbox id="txtcomment" runat="server" text=""></asp:textbox>

Then on item command event, you can get text of your textbox easily.

    protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            TextBox txtComments = (TextBox)e.Item.FindControl("txtcomment");
            string Comments = txtComments.Text; // here you can get text from your textbox

Accept Solution if it helps you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171207.1 | Last Updated 1 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100