Solved

HTMLEncode Question inside gridview PLEASE HELP!!

Posted on 2008-06-24
41
1,449 Views
Last Modified: 2010-05-17
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
Comment
Question by:Ianaldo
  • 22
  • 18
41 Comments
 
LVL 16

Accepted Solution

by:
burakiewicz earned 500 total points
ID: 21856266
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
 
LVL 2

Author Comment

by:Ianaldo
ID: 21856382
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
 
LVL 33

Expert Comment

by:raterus
ID: 21856443
Try simply doing this, instead of a BoundField

<asp:templatefield SortExpression="Description" ItemStyle-Wrap="true">
  <itemtemplate>
    <%# Eval("Description") %>
  </itemtemplate>
</asp:templatefield>
0
 
LVL 2

Author Comment

by:Ianaldo
ID: 21856730
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
 
LVL 16

Expert Comment

by:burakiewicz
ID: 21857679
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
 
LVL 2

Author Comment

by:Ianaldo
ID: 21864602
Hi, when i tried that, i got the error:

Compiler Error Message: CS0103: The name 'HttpUtility' does not exist in the current context
0
 
LVL 16

Expert Comment

by:burakiewicz
ID: 21865390
what version of visual studios do you have and what framework
0
 
LVL 2

Author Comment

by:Ianaldo
ID: 21865477
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
 
LVL 16

Expert Comment

by:burakiewicz
ID: 21865599
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
 
LVL 2

Author Comment

by:Ianaldo
ID: 21865653
System.Web.HttpUtility managed to not display any errors and it compiled, however it didnt display any text, the column was blank?
0
 
LVL 16

Expert Comment

by:burakiewicz
ID: 21865687
you used System.Web.HttpUtility.HtmlDecode()
0
 
LVL 2

Author Comment

by:Ianaldo
ID: 21865723
yep i used that, and i got a blank column
0
 
LVL 2

Author Comment

by:Ianaldo
ID: 21865732
Even when i tried encode it still gave me a blank column
0
 
LVL 16

Expert Comment

by:burakiewicz
ID: 21865758
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
 
LVL 2

Author Comment

by:Ianaldo
ID: 21865850
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
 
LVL 16

Expert Comment

by:burakiewicz
ID: 21865914
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
 
LVL 16

Expert Comment

by:burakiewicz
ID: 21865928
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
 
LVL 2

Author Comment

by:Ianaldo
ID: 21866064
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
 
LVL 2

Author Comment

by:Ianaldo
ID: 21866124
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
 
LVL 16

Expert Comment

by:burakiewicz
ID: 21866176
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 2

Author Comment

by:Ianaldo
ID: 21866278
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
 
LVL 16

Expert Comment

by:burakiewicz
ID: 21866377
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
 
LVL 2

Author Comment

by:Ianaldo
ID: 21866471
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
 
LVL 2

Author Comment

by:Ianaldo
ID: 21866531
sorry not row, i meant column
0
 
LVL 16

Expert Comment

by:burakiewicz
ID: 21866680
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
 
LVL 2

Author Comment

by:Ianaldo
ID: 21866740
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
 
LVL 16

Expert Comment

by:burakiewicz
ID: 21866821
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
 
LVL 2

Author Comment

by:Ianaldo
ID: 21866977
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
 
LVL 2

Author Comment

by:Ianaldo
ID: 21866987
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
 
LVL 16

Expert Comment

by:burakiewicz
ID: 21867175
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
 
LVL 16

Expert Comment

by:burakiewicz
ID: 21874693
0
 
LVL 2

Author Comment

by:Ianaldo
ID: 21916107
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
 
LVL 16

Assisted Solution

by:burakiewicz
burakiewicz earned 500 total points
ID: 21916479
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
 
LVL 2

Author Comment

by:Ianaldo
ID: 21916581
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
 
LVL 16

Expert Comment

by:burakiewicz
ID: 21916653
what code do you have where you call this AdsDataComponent.AdsRow, the loop will problably need to go somewhere else
0
 
LVL 2

Author Comment

by:Ianaldo
ID: 21916768
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
 
LVL 16

Expert Comment

by:burakiewicz
ID: 21916843
can you change it to accept a tableRow and not a table?
0
 
LVL 2

Author Comment

by:Ianaldo
ID: 21916934
Sorry, how do i do that?
0
 
LVL 2

Author Comment

by:Ianaldo
ID: 21933345
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
 
LVL 2

Author Comment

by:Ianaldo
ID: 21933401
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
 
LVL 16

Expert Comment

by:burakiewicz
ID: 21945389
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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now