Hi
Here are some few steps to do this fuctionality
Step 1. Take one gridview control
<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default.aspx.cs” Inherits=”_Default” %>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head runat=”server”>
<title></title>
</head>
<body>
<form id=”form1″ runat=”server”>
<div>
<asp:GridView ID=”GridView1″ runat=”server” AutoGenerateColumns=”False”
onrowdatabound=”GridView1_RowDataBound”>
<Columns>
<asp:TemplateField HeaderText=”Id”>
<ItemTemplate>
<%#Container.DataItemIndex+1 %>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText=”Description1″ DataField=”Desc1″ >
<ItemStyle Font-Bold=”True” Font-Italic=”True”
ForeColor=”#FF3300″ />
</asp:BoundField>
</Columns>
</asp:GridView>
</div></form>
</body>
</html>
Step 2. Click on RowDataBound event of Gridview and write this code in code behind file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;public partial class _Default : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(“Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\Database.mdf;Integrated Security=True;User Instance=True”);
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
FillGrid();
}}
private void FillGrid()
{
SqlDataAdapter da = new SqlDataAdapter(“Select *from tblStory”, con);
DataTable dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
ViewState[“Data”] = e.Row.Cells[1].Text;
if (e.Row.Cells[1].Text.Length > 25)
{
e.Row.Cells[1].Text = e.Row.Cells[1].Text.Substring(0, 25) + “…”;
e.Row.Cells[1].ToolTip = ViewState[“Data”].ToString();
}
}
}
}
Then you will get output like this
Hello…
This information is quite useful
thanks a lot……………….for posting…..
I m glad to know that you liked my artical.