Check this example. Now please take its reference and correct your code.
HTML
<div>
<asp:DataList ID="GetMerge" runat="server" OnItemDataBound="GetMerge_ItemDataBound"
Width="100%">
<ItemTemplate>
<asp:DataList ID="GetUSERCOMMENTS2" runat="server" OnItemDataBound="GetUSERCOMMENTS2_ItemDataBound"
Width="100%">
<ItemTemplate>
<asp:TextBox ID="txtcommentpost" runat="server" CssClass=" form-control" placeholder="Reply..."
MaxLength="500" TextMode="MultiLine"></asp:TextBox>
<asp:DataList ID="GetUSERCOMMENTS3" runat="server">
<ItemTemplate>
<asp:TextBox ID="txtcommentpost2" runat="server" CssClass=" form-control" placeholder="Reply..."
MaxLength="500" TextMode="MultiLine"></asp:TextBox>
</ItemTemplate>
</asp:DataList>
</ItemTemplate>
</asp:DataList>
</ItemTemplate>
</asp:DataList>
</div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$("[id*=txtcommentpost], [id*=txtcommentpost2]").on("keypress", function (e) {
if (e.which != 13) {
var textarea = $(this)[0];
textarea.oninput = function () {
textarea.style.height = "";
textarea.style.height = Math.min(textarea.scrollHeight, 300) + "px";
};
}
else {
e.preventDefault();
return false;
}
});
});
</script>
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
GetMerge.DataSource = GetData();
GetMerge.DataBind();
}
}
private DataTable GetData()
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id"), new DataColumn("Name"), new DataColumn("Country") });
dt.Rows.Add(1, "John Hammond", "United States");
dt.Rows.Add(2, "Mudassar Khan", "India");
return dt;
}
protected void GetMerge_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item)
{
(e.Item.FindControl("GetUSERCOMMENTS2") as DataList).DataSource = GetData();
(e.Item.FindControl("GetUSERCOMMENTS2") as DataList).DataBind();
}
}
protected void GetUSERCOMMENTS2_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item)
{
(e.Item.FindControl("GetUSERCOMMENTS3") as DataList).DataSource = GetData();
(e.Item.FindControl("GetUSERCOMMENTS3") as DataList).DataBind();
}
}
Screenshot