Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1485
  • Last Modified:

HTMLEncode Question inside gridview PLEASE HELP!!

Hi, i have text coming from a database, this text is:
<p><strong> sdfsdfsdf </strong><img src="/fckeditor/editor/images/smiley/msn/devil_smile.gif" alt="" /> sdfsdfsdfsdfs<strong>fdfgdgdgfdg</strong></p>

When i turn on HTMLEncode i get:
&lt;p&gt;&lt;strong&gt; sdfsdfsdf &lt;/strong&gt;&lt;img src=&quot;/fckeditor/editor/images/smiley/msn/devil_smile.gif&quot; alt=&quot;&quot; /&gt; sdfsdfsdfsdfs&lt;strong&gt;fdfgdgdgfdg&lt;/strong&gt;&lt;/p&gt;

What im trying to achieve is:
sdfsdfsdf (smiley image in here) sdfsdfsdfsdfs fdfgdgdgfdg

Ive tried everything searched everything and have no idea, this is my code:


<asp:MultiView ID="MyAdsMultiView" runat="server" ActiveViewIndex="0" EnableTheming="True">
 
				
				<asp:View ID="UserAdsView" runat="server">
				
					<asp:GridView ID="CurrentAdsGrid" runat="server" DataSourceID="CurrentAds" AutoGenerateColumns="False"
						OnRowCommand="CurrentAdsGrid_RowCommand" EnableViewState="False" DataKeyNames="Id" CssClass="item_list"
						ShowFooter="True" AllowPaging="True" EnableSortingAndPagingCallbacks="False" >
						<EmptyDataTemplate>
							You currently have no active work.
							<asp:HyperLink ID="PostAdLink" runat="server" NavigateUrl="~/PostReflection.aspx">Click here to Post a new Reflection.</asp:HyperLink>
						</EmptyDataTemplate>
						
						<Columns>
						
							
						<asp:BoundField DataField="Description" SortExpression="Description" ItemStyle-Wrap="true" HtmlEncode="True" HtmlEncodeFormatString="True" InsertVisible="True">
							<ItemStyle CssClass="normal_weight" />
						</asp:BoundField>
					
							<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ShowReflection.aspx?id={0}"
								DataTextField="Title" SortExpression="Title" HeaderStyle-CssClass="col_title"
								ItemStyle-CssClass="col_title">
                                <HeaderStyle CssClass="col_title" />
                                <ItemStyle CssClass="col_title" />
                            </asp:HyperLinkField>
							
						    	<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="EditReflection.aspx?id={0}"
								Text="Edit" HeaderStyle-CssClass="col_general" ItemStyle-CssClass="col_general">
							        <HeaderStyle CssClass="col_general" />
                                    <ItemStyle CssClass="col_general" />
							</asp:HyperLinkField>
							
							
						</Columns>
						<RowStyle CssClass="row1"></RowStyle>
						<AlternatingRowStyle CssClass="row2"></AlternatingRowStyle>
						<FooterStyle CssClass="item_list_footer"></FooterStyle>
					</asp:GridView>
				    <br />
                    
				</asp:View>
			</asp:MultiView>

Open in new window

0
Ianaldo
Asked:
Ianaldo
  • 22
  • 18
2 Solutions
 
burakiewiczCommented:
on the rowdatabound event have you tried decoding the encoded text?

e.Row.Cells[0].Text=HttpUtility.HtmlDecode(e.Row.Cells[0].Text);
or whatever cell it is in
0
 
IanaldoAuthor Commented:
I dont know how to do that, this is my codebehind for it:

public partial class MyStory : System.Web.UI.Page
{
 
    protected void AdDetails_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        RepeaterItem item = e.Item;
        AdsDataComponent.AdsRow ad = item.DataItem as AdsDataComponent.AdsRow;
 
    }
    protected void AdDetails_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
 
    }
 
}

Open in new window

0
 
raterusCommented:
Try simply doing this, instead of a BoundField

<asp:templatefield SortExpression="Description" ItemStyle-Wrap="true">
  <itemtemplate>
    <%# Eval("Description") %>
  </itemtemplate>
</asp:templatefield>
0
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.

 
IanaldoAuthor Commented:
No that didnt work either, i made a mistake with my code behind, the main code in full is:

public partial class MyStory : System.Web.UI.Page
{
 
    protected void CurrentAdsGrid_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int adId = Convert.ToInt32(e.CommandArgument);
        AdsDB.ExpireAd(adId, Profile.MemberId);
        CurrentAdsGrid.DataBind();
    }
 
    protected void AdDetails_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        RepeaterItem item = e.Item;
        AdsDataComponent.AdsRow ad = item.DataItem as AdsDataComponent.AdsRow;
 
    }
    protected void AdDetails_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
 
    }
 
}

Open in new window

0
 
burakiewiczCommented:
add an event handler for rowdatabound to your gridview

protected void CurrentAdsGrid_OnRowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                    e.Row.Cells[0].Text=HttpUtility.HtmlDecode(e.Row.Cells[0].Text);
             }
        }
0
 
IanaldoAuthor Commented:
Hi, when i tried that, i got the error:

Compiler Error Message: CS0103: The name 'HttpUtility' does not exist in the current context
0
 
burakiewiczCommented:
what version of visual studios do you have and what framework
0
 
IanaldoAuthor Commented:
Visual Studio 2008 and 3.5

Just to clarify, the text in the DB looks like this:

&lt;p&gt;&lt;strong&gt; sdfsdfsdf &lt;/strong&gt;&lt;img src=&quot;/fckeditor/editor/images/smiley/msn/devil_smile.gif&quot; alt=&quot;&quot; /&gt; sdfsdfsdfsdfs&lt;strong&gt;fdfgdgdgfdg&lt;/strong&gt;&lt;/p&gt;

Im able to get it to this:

p><strong> sdfsdfsdf </strong><img src="/fckeditor/editor/images/smiley/msn/devil_smile.gif" alt="" /> sdfsdfsdfsdfs<strong>fdfgdgdgfdg</strong></p>

But i need it displayed as:

sdfsdfsdf (smiley image in here) sdfsdfsdfsdfs fdfgdgdgfdg

Cheers
0
 
burakiewiczCommented:
try this System.Web.HttpUtility;
somethimes the characters act funny, if that doesnt work try
almost the same but sets the string first
protected void CurrentAdsGrid_OnRowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                    string s=HttpUtility.HtmlDecode(e.Row.Cells[0].Text);
                    e.Row.Cells[0].Text
             }
        }
0
 
IanaldoAuthor Commented:
System.Web.HttpUtility managed to not display any errors and it compiled, however it didnt display any text, the column was blank?
0
 
burakiewiczCommented:
you used System.Web.HttpUtility.HtmlDecode()
0
 
IanaldoAuthor Commented:
yep i used that, and i got a blank column
0
 
IanaldoAuthor Commented:
Even when i tried encode it still gave me a blank column
0
 
burakiewiczCommented:
yeah encode wouldnt do it, that worked for me,  code should be this
string s=HttpUtility.HtmlDecode(e.Row.Cells[0].Text);
e.Row.Cells[0].Text = s;--- i forgot that line
0
 
IanaldoAuthor Commented:
I still get the blank screen unfortunately, i think this is just unsolvable: here is my code now in full:


<asp:MultiView ID="MyAdsMultiView" runat="server" ActiveViewIndex="0" EnableTheming="True" >
			
<asp:View ID="UserAdsView" runat="server" >
				
<asp:GridView ID="CurrentAdsGrid" runat="server" DataSourceID="CurrentAds" AutoGenerateColumns="False"
OnRowCommand="CurrentAdsGrid_RowCommand" DataKeyNames="Id" OnRowDataBound="CurrentAdsGrid_OnRowDataBound" ShowFooter="True" AllowPaging="True">
<EmptyDataTemplate>
You currently have no active work.
<asp:HyperLink ID="PostAdLink" runat="server" NavigateUrl="~/PostReflection.aspx">Click here to Post a new Reflection.</asp:HyperLink>
</EmptyDataTemplate>
						
<Columns>
										
<asp:Templatefield ItemStyle-Wrap="true" >
<ItemTemplate >
        
<asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>'></asp:Label>
                
</ItemTemplate>
</asp:Templatefield>                           
							<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="ShowReflection.aspx?id={0}"
								DataTextField="Title" SortExpression="Title" HeaderStyle-CssClass="col_title"
								ItemStyle-CssClass="col_title">
<HeaderStyle CssClass="col_title" />
<ItemStyle CssClass="col_title" />
</asp:HyperLinkField>
						
</Columns>
<RowStyle CssClass="row1"></RowStyle>
<AlternatingRowStyle CssClass="row2"></AlternatingRowStyle>
<FooterStyle CssClass="item_list_footer"></FooterStyle>
</asp:GridView>
<br />
</asp:View>
</asp:MultiView>
 
 
//And the codebehind:
 
public partial class MyStory : System.Web.UI.Page
{
 
    protected void CurrentAdsGrid_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int adId = Convert.ToInt32(e.CommandArgument);
        AdsDB.ExpireAd(adId, Profile.MemberId);
        CurrentAdsGrid.DataBind();
 
    }
 
    protected void AdDetails_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        RepeaterItem item = e.Item;
        AdsDataComponent.AdsRow ad = item.DataItem as AdsDataComponent.AdsRow;
 
    }
    protected void AdDetails_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
 
    }
 
    protected void CurrentAdsGrid_OnRowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string s = HttpUtility.HtmlDecode(e.Row.Cells[0].Text);
            e.Row.Cells[0].Text = s;
            
        }
    }
 
    protected void CurrentAdsGrid_RowDataBound(object sender, GridViewRowEventArgs e)
    {
 
    }
 
}
 
 
Thanks

Open in new window

0
 
burakiewiczCommented:
here is 1 more way that i have done it
string s = e.Row.Cells[0].Text;
e.Row.Cells[0].Text=s;--put a breakpoint here and verify that s has text
           
0
 
burakiewiczCommented:
oops here it is
string s = e.Row.Cells[0].Text;
s = s.Replace("&lt;", "<").Replace("&gt;",">").Replace("&quot;","'");
e.Row.Cells[0].Text=s;--put a breakpoint here and verify that s has text and it looks like <p>
0
 
IanaldoAuthor Commented:
Sorry, i still get a blank screen :(

i even tried:

string s = e.Row.Cells[0].Text;
s = ("ian");
e.Row.Cells[0].Text=s;

to see if it was reading s even, and it did display ian, but when i try to read the db field "description" it wont display
0
 
IanaldoAuthor Commented:
I think what the problem is, is that this little function is not reading the data from the database field "description" and instead, does the function reading no text, and displays no text, so how do i get it to read from the DB field "description" first and then play with this text and display it?
0
 
burakiewiczCommented:
hmmmm....try changing this
<asp:BoundField DataField="Description" SortExpression="Description" ItemStyle-Wrap="true" HtmlEncode="True" HtmlEncodeFormatString="True" InsertVisible="True">
<ItemStyle CssClass="normal_weight" />
</asp:BoundField>
to
<asp:BoundField DataField="Description" SortExpression="Description"  InsertVisible="True">
<ItemStyle CssClass="normal_weight" />
</asp:BoundField>
0
 
IanaldoAuthor Commented:
That works in that it turns the data in the database:

&lt;p&gt;&lt;strong&gt; sdfsdfsdf &lt;/strong&gt;&lt;img src=&quot;/fckeditor/editor/images/smiley/msn/devil_smile.gif&quot; alt=&quot;&quot; /&gt; sdfsdfsdfsdfs&lt;strong&gt;fdfgdgdgfdg&lt;/strong&gt;&lt;/p&gt;

to this now:

<p><strong> sdfsdfsdf </strong><img src="/fckeditor/editor/images/smiley/msn/devil_smile.gif" alt="" /> sdfsdfsdfsdfs<strong>fdfgdgdgfdg</strong></p>

But i need to get the above to:

sdfsdfsdf (smiley image in here) sdfsdfsdfsdfs fdfgdgdgfdg


Thanks burakiewicz
0
 
burakiewiczCommented:
ok, so it displays this on the screen now?
<p><strong> sdfsdfsdf </strong><img src="/fckeditor/editor/images/smiley/msn/devil_smile.gif" alt="" /> sdfsdfsdfsdfs<strong>fdfgdgdgfdg</strong></p>
instead of
&lt;p&gt;&lt;strong&gt; sdfsdfsdf &lt;/strong&gt;&lt;img src=&quot;/fckeditor/editor/images/smiley/msn/devil_smile.gif&quot; alt=&quot;&quot; /&gt; sdfsdfsdfsdfs&lt;strong&gt;fdfgdgdgfdg&lt;/strong&gt;&lt;/p&gt;

do this and see what you get for a value
string s = e.Row.Cells[0].Text;
e.Row.Cells[0].Text=s;-- put a breakpint here and show me what you get for s
0
 
IanaldoAuthor Commented:
Doing that i got:

&lt;p&gt;&lt;strong&gt; sdfsdfsdf &lt;/strong&gt;&lt;img src=&quot;/NHS%20Reflective%20E-portfolio/fckeditor/editor/images/smiley/msn/devil_smile.gif&quot; alt=&quot;&quot; /&gt; sdfsdfsdfsdfs&lt;strong&gt;fdfgdgdgfdg&lt;/strong&gt;&lt;/p&gt;

Thats the data as it is in the db, keep in mind i have many records being read and displayed from the db, i dont know if that makes much difference, but its just that one row that i need displaying the correct format
0
 
IanaldoAuthor Commented:
sorry not row, i meant column
0
 
burakiewiczCommented:
yeah i know, that was the desired effect.encoding is always a pain, i know ive had you do something like this but try
try this
string s = e.Row.Cells[0].Text;
e.Row.Cells[0].Text="";--verify that the text is set to ""
s = s.Replace("&lt;", "<").Replace("&gt;",">").Replace("&quot;","'");-- here s should be #1
e.Row.Cells[0].Text="MyText:" +  s;--see if you see anything

#1
<p><strong> sdfsdfsdf </strong><img src="/fckeditor/editor/images/smiley/msn/devil_smile.gif" alt="" /> sdfsdfsdfsdfs<strong>fdfgdgdgfdg</strong></p>
0
 
IanaldoAuthor Commented:
Now what i got was:

MyText:&lt;p&gt;&lt;strong&gt; sdfsdfsdf &lt;/strong&gt;&lt;img src=&quot;/NHS%20Reflective%20E-portfolio/fckeditor/editor/images/smiley/msn/devil_smile.gif&quot; alt=&quot;&quot; /&gt; sdfsdfsdfsdfs&lt;strong&gt;fdfgdgdgfdg&lt;/strong&gt;&lt;/p&gt;
0
 
burakiewiczCommented:
ok, remove MyText-- if this doesnt work, then im not sure why it wont work
s = s.Replace("&lt;", "<").Replace("&gt;",">").Replace("&quot;","'");
e.Row.Cells[0].Text=s;what do you see at this line for s

Are you trying to set the text in a label or in a control
or the last thing i can think of by looking at yor code
string s = e.Row.Cells[0].Text;
s = s.Replace("&lt;", "<").Replace("&gt;",">").Replace("&quot;","'");--
Label lbl = (Label)e.Row.Cells[0].Controls[0];
lbl.Text=s;
e.Row.Cells[0].Controls.Clear();
e.Row.Cells[0].Controls[.Add(lbl);
0
 
IanaldoAuthor Commented:
When i tried that i got:
Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index

However i just tried:

                string s = e.Row.Cells[0].Text;
                e.Row.Cells[0].Text="";
                s = s.Replace("p", "IANNN").Replace("&gt;", ">").Replace("&quot;", "'");
                e.Row.Cells[0].Text="MyText:" +  s;

MyText:&amIANNN;lt;IANNN&amIANNN;gt;&amIANNN;lt;strong&amIANNN;gt; sdfsdfsdf &amIANNN;lt;/strong&amIANNN;gt;&amIANNN;lt;img src=&amIANNN;quot;/NHS%20Reflective%20E-IANNNortfolio/fckeditor/editor/images/smiley/msn/devil_smile.gif&amIANNN;quot; alt=&amIANNN;quot;&amIANNN;quot; /&amIANNN;gt; sdfsdfsdfsdfs&amIANNN;lt;strong&amIANNN;gt;fdfgdgdgfdg&amIANNN;lt;/strong&amIANNN;gt;&amIANNN;lt;/IANNN&amIANNN;gt;

However i need it to display in html formatted code, like bold will show up if a field reads <b>some text</b> it will be "some text" in bold format

This is so tough! :(

0
 
IanaldoAuthor Commented:
sorry the error i got was when i tried the:

string s = e.Row.Cells[0].Text;
s = s.Replace("&lt;", "<").Replace("&gt;",">").Replace("&quot;","'");--
Label lbl = (Label)e.Row.Cells[0].Controls[0];
lbl.Text=s;
e.Row.Cells[0].Controls.Clear();
e.Row.Cells[0].Controls[.Add(lbl);
0
 
burakiewiczCommented:
ok try this -- i know, all of the solutions work on mine and i have vs 2008 3.5
string s = e.Row.Cells[0].Text;
s = s.Replace("&lt;", "<").Replace("&gt;",">").Replace("&quot;","'");--
Label lbl = new Label();
lbl.Text=s;
e.Row.Cells[0].Controls.Clear();
e.Row.Cells[0].Controls[.Add(lbl);
0
 
burakiewiczCommented:
0
 
IanaldoAuthor Commented:
Sorry ive taken so long to get back, but ive finally narrowed it down, i have this code, however this code checks the first row and changes that to whats needed, how do i change the below code to change all the rows including the first one, instead of just one:


        private static AdsDataComponent.AdsRow GetRowss(AdsDataComponent.AdsDataTable table)
        {
            if (table != null && table.Rows.Count > 0)
            {
                AdsDataComponent.AdsRow row;
                row = table.Rows[0] as AdsDataComponent.AdsRow;
                row.URL = System.Web.HttpUtility.UrlDecode(row.URL);
                row.Title = System.Web.HttpUtility.HtmlDecode(row.Title);
                row.Description = System.Web.HttpUtility.HtmlDecode(row.Description);
                row.Location = System.Web.HttpUtility.HtmlDecode(row.Location);
                return row;
            }
            else
                return null;
        }

Open in new window

0
 
burakiewiczCommented:
row = table.Rows[0] as AdsDataComponent.AdsRow; will always get row 0, you would need to increment this
               
you will need to loop throught the rows, something like this
--code below



for (int i = 0; i < table.Rows.Count - 1; i++)
                {
                    AdsDataComponent.AdsRow row;
                    row = table.Rows[i] as AdsDataComponent.AdsRow;
                    row.URL = System.Web.HttpUtility.UrlDecode(row.URL);
                    row.Title = System.Web.HttpUtility.HtmlDecode(row.Title);
                    row.Description = System.Web.HttpUtility.HtmlDecode(row.Description);
                    row.Location = System.Web.HttpUtility.HtmlDecode(row.Location);
                }

Open in new window

0
 
IanaldoAuthor Commented:
i got an error with that, it said:

GetFirstRow(AdsDataComponent.AdsDataTable)': not all code paths return a value


		private static AdsDataComponent.AdsRow GetFirstRow(AdsDataComponent.AdsDataTable table)
		{
            for (int i = 0; i < table.Rows.Count - 1; i++)
            {
                AdsDataComponent.AdsRow row;
                row = table.Rows[i] as AdsDataComponent.AdsRow;
                row.URL = System.Web.HttpUtility.UrlDecode(row.URL);
                row.Title = System.Web.HttpUtility.HtmlDecode(row.Title);
                row.Description = System.Web.HttpUtility.HtmlDecode(row.Description);
                row.Location = System.Web.HttpUtility.HtmlDecode(row.Location);
 
            }
            
		}

Open in new window

0
 
burakiewiczCommented:
what code do you have where you call this AdsDataComponent.AdsRow, the loop will problably need to go somewhere else
0
 
IanaldoAuthor Commented:
The only thing that i understand, that Adsrow is created here: in the file ads.xsd


<xs:element name="AdsDataComponent" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msprop:Generator_UserDSName="AdsDataComponent" msprop:Generator_DataSetName="AdsDataComponent">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="Ads" msprop:Generator_UserTableName="Ads" msprop:Generator_RowDeletedName="AdsRowDeleted" msprop:Generator_TableClassName="AdsDataTable" msprop:Generator_RowChangedName="AdsRowChanged" msprop:Generator_RowClassName="AdsRow" msprop:Generator_RowChangingName="AdsRowChanging" msprop:Generator_RowEvArgName="AdsRowChangeEvent" msprop:Generator_RowEvHandlerName="AdsRowChangeEventHandler" msprop:Generator_TablePropName="Ads" msprop:Generator_TableVarName="tableAds" msprop:Generator_RowDeletingName="AdsRowDeleting">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Id" msdata:ReadOnly="true" msdata:AutoIncrement="true" msprop:Generator_UserColumnName="Id" msprop:Generator_ColumnPropNameInRow="Id" msprop:Generator_ColumnVarNameInTable="columnId" msprop:Generator_ColumnPropNameInTable="IdColumn" type="xs:int" />
              <xs:element name="MemberId" msprop:Generator_UserColumnName="MemberId" msprop:Generator_ColumnPropNameInRow="MemberId" msprop:Generator_ColumnVarNameInTable="columnMemberId" msprop:Generator_ColumnPropNameInTable="MemberIdColumn" type="xs:int" />
              <xs:element name="CategoryId" msprop:Generator_UserColumnName="CategoryId" msprop:Generator_ColumnPropNameInRow="CategoryId" msprop:Generator_ColumnVarNameInTable="columnCategoryId" msprop:Generator_ColumnPropNameInTable="CategoryIdColumn" type="xs:int" />
              <xs:element name="Title" msprop:Generator_UserColumnName="Title" msprop:Generator_ColumnPropNameInRow="Title" msprop:Generator_ColumnVarNameInTable="columnTitle" msprop:Generator_ColumnPropNameInTable="TitleColumn">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="100" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
              <xs:element name="Description" msprop:Generator_UserColumnName="Description" msprop:Generator_ColumnPropNameInRow="Description" msprop:Generator_ColumnVarNameInTable="columnDescription" msprop:Generator_ColumnPropNameInTable="DescriptionColumn">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="1073741823" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
              <xs:element name="URL" msprop:Generator_UserColumnName="URL" msprop:Generator_ColumnPropNameInRow="URL" msprop:Generator_ColumnVarNameInTable="columnURL" msprop:Generator_ColumnPropNameInTable="URLColumn">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="500" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
              <xs:element name="Location" msprop:Generator_UserColumnName="Location" msprop:Generator_ColumnPropNameInRow="Location" msprop:Generator_ColumnVarNameInTable="columnLocation" msprop:Generator_ColumnPropNameInTable="LocationColumn">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="50" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
              <xs:element name="ExpirationDate" msprop:Generator_UserColumnName="ExpirationDate" msprop:Generator_ColumnPropNameInRow="ExpirationDate" msprop:Generator_ColumnVarNameInTable="columnExpirationDate" msprop:Generator_ColumnPropNameInTable="ExpirationDateColumn" type="xs:dateTime" minOccurs="0" />
              <xs:element name="DateCreated" msprop:Generator_UserColumnName="DateCreated" msprop:Generator_ColumnPropNameInRow="DateCreated" msprop:Generator_ColumnVarNameInTable="columnDateCreated" msprop:Generator_ColumnPropNameInTable="DateCreatedColumn" type="xs:dateTime" />
              <xs:element name="DateApproved" msprop:Generator_UserColumnName="DateApproved" msprop:Generator_ColumnPropNameInRow="DateApproved" msprop:Generator_ColumnVarNameInTable="columnDateApproved" msprop:Generator_ColumnPropNameInTable="DateApprovedColumn" type="xs:dateTime" minOccurs="0" />
              <xs:element name="NumViews" msprop:Generator_UserColumnName="NumViews" msprop:Generator_ColumnPropNameInRow="NumViews" msprop:Generator_ColumnVarNameInTable="columnNumViews" msprop:Generator_ColumnPropNameInTable="NumViewsColumn" type="xs:int" />
              <xs:element name="NumResponses" msprop:Generator_UserColumnName="NumResponses" msprop:Generator_ColumnPropNameInRow="NumResponses" msprop:Generator_ColumnVarNameInTable="columnNumResponses" msprop:Generator_ColumnPropNameInTable="NumResponsesColumn" type="xs:int" />
              <xs:element name="AdLevel" msprop:Generator_UserColumnName="AdLevel" msprop:Generator_ColumnPropNameInRow="AdLevel" msprop:Generator_ColumnVarNameInTable="columnAdLevel" msprop:Generator_ColumnPropNameInTable="AdLevelColumn" type="xs:int" />
              <xs:element name="AdStatus" msprop:Generator_UserColumnName="AdStatus" msprop:Generator_ColumnPropNameInRow="AdStatus" msprop:Generator_ColumnVarNameInTable="columnAdStatus" msprop:Generator_ColumnPropNameInTable="AdStatusColumn" type="xs:int" />
              <xs:element name="PreviewImageId" msprop:Generator_UserColumnName="PreviewImageId" msprop:Generator_ColumnPropNameInRow="PreviewImageId" msprop:Generator_ColumnVarNameInTable="columnPreviewImageId" msprop:Generator_ColumnPropNameInTable="PreviewImageIdColumn" type="xs:int" minOccurs="0" />
              <xs:element name="MemberName" msprop:Generator_UserColumnName="MemberName" msprop:Generator_ColumnPropNameInRow="MemberName" msprop:Generator_ColumnVarNameInTable="columnMemberName" msprop:Generator_ColumnPropNameInTable="MemberNameColumn">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="256" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
              <xs:element name="CategoryName" msprop:Generator_UserColumnName="CategoryName" msprop:Generator_ColumnPropNameInRow="CategoryName" msprop:Generator_ColumnVarNameInTable="columnCategoryName" msprop:Generator_ColumnPropNameInTable="CategoryNameColumn">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="50" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="Photos" msprop:Generator_UserTableName="Photos" msprop:Generator_RowDeletedName="PhotosRowDeleted" msprop:Generator_TableClassName="PhotosDataTable" msprop:Generator_RowChangedName="PhotosRowChanged" msprop:Generator_RowClassName="PhotosRow" msprop:Generator_RowChangingName="PhotosRowChanging" msprop:Generator_RowEvArgName="PhotosRowChangeEvent" msprop:Generator_RowEvHandlerName="PhotosRowChangeEventHandler" msprop:Generator_TablePropName="Photos" msprop:Generator_TableVarName="tablePhotos" msprop:Generator_RowDeletingName="PhotosRowDeleting">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Id" msdata:ReadOnly="true" msdata:AutoIncrement="true" msprop:Generator_UserColumnName="Id" msprop:Generator_ColumnPropNameInRow="Id" msprop:Generator_ColumnVarNameInTable="columnId" msprop:Generator_ColumnPropNameInTable="IdColumn" type="xs:int" />
              <xs:element name="AdId" msprop:Generator_UserColumnName="AdId" msprop:Generator_ColumnPropNameInRow="AdId" msprop:Generator_ColumnVarNameInTable="columnAdId" msprop:Generator_ColumnPropNameInTable="AdIdColumn" type="xs:int" />
              <xs:element name="IsMainPreview" msprop:Generator_UserColumnName="IsMainPreview" msprop:Generator_ColumnPropNameInRow="IsMainPreview" msprop:Generator_ColumnVarNameInTable="columnIsMainPreview" msprop:Generator_ColumnPropNameInTable="IsMainPreviewColumn" type="xs:boolean" />
              <xs:element name="DateCreated" msprop:Generator_UserColumnName="DateCreated" msprop:Generator_ColumnPropNameInRow="DateCreated" msprop:Generator_ColumnVarNameInTable="columnDateCreated" msprop:Generator_ColumnPropNameInTable="DateCreatedColumn" type="xs:dateTime" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>

Open in new window

0
 
burakiewiczCommented:
can you change it to accept a tableRow and not a table?
0
 
IanaldoAuthor Commented:
Sorry, how do i do that?
0
 
IanaldoAuthor Commented:
Ive finally figured it out, and it was a combination of your first and last answer really, not deep into the cs and writing new procedures as i found myself doing, however, can you tell me do i now count the number of rows for the for loop, here is the working code, i put 6 in there so it would loop:

    protected void CurrentAdsGrid_OnRowDataBound(object sender, GridViewRowEventArgs e)
    {
        for (int i = 0; i < 6 - 1; i++)
        {
            string desc;
            desc = System.Web.HttpUtility.HtmlDecode(e.Row.Cells[0].Text);
            e.Row.Cells[0].Text = desc;
        }
       
    }
0
 
IanaldoAuthor Commented:
not do i, can u tell me how to count the rows and loop through

Thanks for all your help, and sorry this has dragged on so long!!
0
 
burakiewiczCommented:
you could do something like this after the grid is bound. that will loop through all the rows in the grid
foreach (GridViewRow gvr in CurrentAdsGrid.Rows)
{

}

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 22
  • 18
Tackle projects and never again get stuck behind a technical roadblock.
Join Now