how to break a line like (wraptrext)

Posted by Oswaldlily under ASP.NET on 10/11/2011 | Points: 10 | Views : 1405 | Status : [Member] | Replies : 7
I have written query and binded to gridview

In my design page i have the follwoing line alone
<asp:gridview id="gv" runat="server"></asp:gridview>

now my outcome is in table values i have lengthy word of 100 charaters.
i need to break that line automatically while displayin in gridview..

Plz don com out by asnwering "In design page include columns-templatefield-headertext-"
I don need this method..




Responses

Posted by: SheoNarayan on: 10/11/2011 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
What are the last two sentences, could you please rephrase?

thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 10/11/2011 [Member] Starter | Points: 25

Up
0
Down
You can use row databound event to handle this
on page load register this event
GridView2.RowDataBound += new GridViewRowEventHandler(GridView2_RowDataBound);

Then define this method
void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)

{
if (e.Row.RowType == DataControlRowType.Header || e.Row.RowType == DataControlRowType.DataRow)
{
foreach (TableCell item in e.Row.Cells)
{
item.Wrap = true;
item.Width = 100;
}
}
}


This is a duplicate post,
http://www.dotnetfunda.com/forums/thread6282-how-to-use-wrap-for-gridview.aspx
I think i had answered this, please refer my last answer in the post.

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Oswaldlily on: 10/12/2011 [Member] Starter | Points: 25

Up
0
Down
@Ndebata
In my page load,
gridview.rowdatabound not accepting

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Oswaldlily on: 10/12/2011 [Member] Starter | Points: 25

Up
0
Down
@SheoNarayan
afsdddddddddddddddddguhjulllllllllgerefnhjsidafhcnhdsufyxiundehuiasyhbfceyregyaxuuguxzneyhyryxuercbyegyrcgbregryewbycb

lik this with no spaces

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 10/12/2011 [Member] Starter | Points: 25

Up
0
Down
post your code we will take a look at it.

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Oswaldlily on: 10/12/2011 [Member] Starter | Points: 25

Up
0
Down
In my design page i has only gridview
<asp:gridview runat="server id="gv"></asp:gridview>

In my codebehind under button click i have lik below

By using mapper i have called my function as follows
id=txtbox1.text
name=txtbox2.text
chap=txtbox3.text
gv.datasource=_mapper.functionname(id,name,chap)
gv.databind()


Notes:from database directly binded to gridview.
so my lengthy values in database table.
should i need to break using query??
or after binding can i break in gridview dynamically?

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 10/12/2011 [Member] Starter | Points: 25

Up
0
Down
Dear Friend,

Please take a look at the attached sample implemented using row databound event
There a variable NumberOfCharacterInWrap is used to specify the number of characters after what text will be wrapped.

Thanks,
Debata
 Download source file

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response