Monday, November 19, 2012

// // Leave a Comment

how to use space in xslt

Try using the entity   instead of  
Read More

Friday, August 3, 2012

// // Leave a Comment

Convert Dataset to HTML table


public string CreateHtmlTableRows(DataTable targetTable, string strtblName, List<string> strLinkList,List<string> strRejectedColumnList)
    {
        System.Text.StringBuilder myBuilder = new System.Text.StringBuilder();
     
        if (strtblName != "")
            myBuilder.Append("<table Id='" + strtblName + "' border='1px' cellpadding='10px' cellspacing='10px' ");
        else
            myBuilder.Append("<table border='0px' cellpadding='5px' cellspacing='5px' ");
        myBuilder.Append("style='width: 100%;'>");
        //Add the headings row.
        myBuilder.Append("<tr align='left' valign='top' style='  background-color: #5D7B9D;font-weight: bold;color: White;'>"); //grdHeader class will be in CSS file

        foreach (DataColumn myColumn in targetTable.Columns)
        {
            if (!strRejectedColumnList.Contains(myColumn.ColumnName))
            {
                myBuilder.Append("<td align='left' valign='top'><label style=\"cursor:pointer;\" onclick=\"clickonheader(" + myColumn.ColumnName + ");\">");
                myBuilder.Append(myColumn.ColumnName);
                myBuilder.Append("</label></td>");
            }
        }
        myBuilder.Append("</tr>");
        //Add the data rows.
        int intI = 0;
        int totRow = targetTable.Rows.Count - 1;
        bool bGetTotalRecs = false;
        foreach (DataRow myRow in targetTable.Rows)
        {

            if (intI % 2 == 0)
                myBuilder.Append("<tr align='left' style=' border-right: 2px solid #A7A6AA;border-bottom: 2px solid #A7A6AA;border-left: 2px solid #A7A6AA;border-top: 2px solid #A7A6AA;padding: 4px;'>"); //'grdOddRow'class will be in CSS file
            else
                myBuilder.Append("<tr align='left' style=' border-right: 2px solid #A7A6AA;border-bottom: 2px solid #A7A6AA;border-left: 2px solid #A7A6AA;border-top: 2px solid #A7A6AA; background-color: #FFFFFF;color: #284775;'>"); //''grdEvenRow''class will be in CSS file

            int colcount = 0;
            foreach (DataColumn myColumn in targetTable.Columns)
            {
                if (!strRejectedColumnList.Contains(targetTable.Columns[colcount].ColumnName))
                {
                    if (strLinkList.Contains(targetTable.Columns[colcount].ColumnName))
                    {
                        myBuilder.Append("<td align='left' valign='middle'><b><a href='#toShow'><label id='" + targetTable.Columns[colcount].ColumnName + "_" + myRow[myColumn.ColumnName].ToString() + "'");
                        myBuilder.Append(" onclick=\"clickonlink('" + targetTable.Columns[colcount].ColumnName + "'," + myRow[myColumn.ColumnName].ToString() + ");\" style=\"cursor:pointer;\">");
                        myBuilder.Append(myRow[myColumn.ColumnName].ToString());
                        myBuilder.Append("</label></a></b></td>");
                    }
                    else
                    {
                        myBuilder.Append("<td align='left' valign='top'><b><label id='" + targetTable.Columns[colcount].ColumnName + "_" + myRow[myColumn.ColumnName].ToString() + "'>");
                        myBuilder.Append(myRow[myColumn.ColumnName].ToString());
                        myBuilder.Append("</label></b></td>");
                    }
                }
                else
                {
                    if (!bGetTotalRecs)
                    {
                        if (targetTable.Columns[colcount].ColumnName == "totalrecs")
                        {
                            myBuilder.Append("<input type=\"hidden\" id=\"hidTotalRecs\" value=\"" + myRow[myColumn.ColumnName].ToString() + "\"  />");
                            bGetTotalRecs = true;
                        }
                    }
                }
                colcount++;

            }
            myBuilder.Append("</tr>");
            intI += 1;
        }
        //Close tags.
        return myBuilder.Append("</table>").ToString();
    }
Read More

Tuesday, June 19, 2012

// // Leave a Comment

How to retain or maintain current scrolling position even after a postback in an ASP.NET Page

If you are pressing a button or doing any post-back action in the middle of a scrolling page. Then the page will render back from the server and your cursor is on the top of the page. So you re-scroll to the position where you do the previous action.

To resolve this problem .NET Provide a wonderful solution 

The solution is as follows 

<%@ Page MaintainScrollPositionOnPostback="true" %>
Read More