none
& is shown as &amp RRS feed

  • Question

  •  

    hai,

    i retrieve some data from database and store it in a Dataset.And run a for loop to that dataset and assign some values to the datatable.my problem is when i assign this values to the datatable any & is converted into & ,i.e., a & b is shown as a & b .how can i solve this please help me.

    Monday, May 19, 2008 11:47 AM

All replies

  •  karthick wrote:

     

    hai,

    i retrieve some data from database and store it in a Dataset.And run a for loop to that dataset and assign some values to the datatable.my problem is when i assign this values to the datatable any & is converted into & ,i.e., a & b is shown as a & b .how can i solve this please help me.



    What is the data type for an object that contains "a & b" as its current value?  String or a custom type?

    Rudedog
    Monday, May 19, 2008 1:26 PM
  • it is string

    Monday, May 19, 2008 1:36 PM
  • Hi,

     

    You mean the string including “&” became “&” in your data, so you want to solve this problem, right?  But I am afraid it is not a problem.

     

    You know, in the new W3C HTML protocols, “&” is represented by “&” in a Unicode format, so it is a normal change, without any issue here, I think. 

    For more detail, you could refer to HTML Document Representation. (Search “&” to check)

     

    Hope these can help.  Any more problem, be free to ask, please.

     

    Thanks,

     

    Best Regards,

    Lingzhi

     

    Thursday, May 22, 2008 6:55 AM
    Moderator
  • hi,

    if the text is a&b.it has been shown as a & b.eventhough it is w3c format my client want the actual data to be displayed as itself that what he entered.

    Thursday, May 22, 2008 10:18 AM
  • I sort of understand the problem. The DB or whatever is outputting a&b. For somereason the script ing then converting the & in the & to another &, so the total output is a&b
    Thursday, May 22, 2008 10:59 AM
  • How do you display data? I mean do you bind dataset to any specific control or you are using any code to build your own HTML? Can you post more details here?

     

    Friday, May 23, 2008 5:29 PM
    Moderator
  • Hai,

    This is my code,

    for (int ncount = 0; ncount <= grdemploeedetails.Rows.Count - 1; ncount++)

    {

    CheckBox chkselect = (CheckBox)grdemploeedetails.Rows[ncount].FindControl("chkselect");

    if (chkselect.Checked)

    {

    dtemp = (DataTable)ViewState["emptable"];

    dremp = dtemp.NewRow();

    dremp[0] = grdemploeedetails.Rows[ncount].Cells[0].Text;

    dremp[1] = grdemploeedetails.Rows[ncount].Cells[1].Text;

    string strdept = grdemploeedetails.Rows[ncount].Cells[2].Text;

    dremp[2] =strdept.Replace("&amp;","&");

    string strsubdept = grdemploeedetails.Rows[ncount].Cells[3].Text;

    dremp[3] = strsubdept.Replace("&amp;", "&");

    string strgrade = grdemploeedetails.Rows[ncount].Cells[4].Text;

    dremp[4] = strgrade.Replace("&amp;", "&");

    dremp[5] = grdemploeedetails.Rows[ncount].Cells[5].Text.Trim();

    dtemp.Rows.Add(dremp);

    grdselectedemployee.DataSource = dtemp;

    grdselectedemployee.DataBind();

    }

    }

     In the grdselectedemployee grid all the & where shown as &amp;.How can i solve this.
    Monday, May 26, 2008 8:16 AM