• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 469
  • Last Modified:

how to remove &gt in the grid

hi
i am printing some value stored in db to the gridview. on and off i get this in the text
 --->
how can i remove this &gt?
0
samir25
Asked:
samir25
  • 6
  • 5
1 Solution
 
DhaestCommented:
Does your string that fills the cell holds a ">" sign ?
0
 
renjurdevanCommented:
Server.HtmlEncode() and Server.HtmlDecode() function used to convert Html tags

Regards
Renju
0
 
samir25Author Commented:
yes i checked it had..
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
samir25Author Commented:
whats the diff bet the two
0
 
renjurdevanCommented:



Server.HtmlEncode() used to encode html tag ie > will become &gt

and second one

Server.HtmlDecode()  used to decode html tag &gt will become >

Regards
Renju
0
 
samir25Author Commented:
ok ... can i use this server.encode in the aspx page ... in the gridview. i guess i need to put<%????
can tell me exactlu
0
 
samir25Author Commented:
like i have this
<asp:BoundField DataField="xml_data" headertext="Except./.....
0
 
renjurdevanCommented:
I hope you should have used itemtemplate instead of BoundField

If it been so you can hadle these things in RowDataBound event of GridView

ie
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {// Get  XMl_data here
// I suppose you have value in szValue
//
//     e.Row.Cells[0].Text = Server.HtmlDecode(szValue); where Cell depends on your grid column
    }

Regards
Renju
0
 
samir25Author Commented:
i have all the values in boundfield. so you mean i should convert it into template column?
0
 
renjurdevanCommented:
IF you want to perform any operation before databinding you should make that particular column alone as template column not all

Regards
Renju

0
 
samir25Author Commented:
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            e.Row.Cells(4).Text = Server.HtmlDecode(xml_Data)
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(4).Text = "Exception Text"
        End If
    End Sub

xml_data is the field i am usin gin boundfield...i m using              da.Fill(dt)
so how do i refer the the row ...
0
 
renjurdevanCommented:

 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
        DataRowView obj =  ((System.Data.DataRowView)e.Row.DataItem);

        string str =   obj.Row["xml_Data"].ToString();
        }
     
e.Row.Cells[0].Text = Server.HtmlDecode(str );
    }

Please refer

http://msdn2.microsoft.com/en-US/library/aa479353.aspx

Regards
Renju
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now