Hi sat,
Please take refere the below code and correct your code.
HTML
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:BoundField DataField="Sentence" HeaderText="Sentence" />
</Columns>
</asp:GridView>
Namespaces
C#
using System.Data;
VB.Net
Imports System.Data
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[1] { new DataColumn("Sentence", typeof(string)) });
dt.Rows.Add("First you go there. Open the door, Welcome the guest. Offer the help. Thank him for reaching you.");
this.GridView1.DataSource = dt;
this.GridView1.DataBind();
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[0].Text = e.Row.Cells[0].Text.Replace(".", ".</br>").Replace(",", ",</br>");
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim dt As DataTable = New DataTable()
dt.Columns.AddRange(New DataColumn(0) {New DataColumn("Sentence", GetType(String))})
dt.Rows.Add("First you go there. Open the door, Welcome the guest. Offer the help. Thank him for reaching you.")
Me.GridView1.DataSource = dt
Me.GridView1.DataBind()
End If
End Sub
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Cells(0).Text = e.Row.Cells(0).Text.Replace(".", ".</br>").Replace(",", ",</br>")
End If
End Sub
Screenshot
