studio NETSOULS

Applying Web To Your Business

This example is useful when you need to add new row in the gridview. Here  to can add the link URL runtime.

Add a placeholder in the HTML page.

   1: <asp:PlaceHolder ID="phGrid" runat="server"></asp:PlaceHolder>

Now create the gridview run time

   1: private void BindGrid()
   2:   {
   3:     // Create new instance of gridview
   4:       GridView gvNew = new GridView();
   5:       gvNew.ID = "ItemGrid";
   6:       gvNew.SkinID = "ListView";
   7:       gvNew.Width = 300;
   8:  
   9:       DataTable dt = Datasource();
  10:       if (dt.Columns.Count > 1)
  11:       {
  12:             // Assign RowDataBound handler. This will add link URL dynamically.
  13:           gvNew.RowDataBound += new GridViewRowEventHandler(gvNew_RowDataBound);
  14:           gvNew.DataSource = dt;
  15:           gvNew.DataBind();
  16:       }
  17:       else
  18:       {
  19:             // Some Comments
  20:       }
  21:      
  22:       phGrid.Controls.Add(gvNew);
  23:  
  24:   }
   1: protected void gvNew_RowDataBound(object sender, GridViewRowEventArgs e)
   2:  {
   3:      int random = 1;
   4:      int count = e.Row.Cells.Count;
   5:  
   6:      if (e.Row.RowType == DataControlRowType.DataRow)
   7:      {
   8:          string str = e.Row.Cells[0].Text;
   9:      }
  10:      else if (e.Row.RowType == DataControlRowType.Footer)
  11:      {
  12:  
  13:          Label lblEdit = new Label();
  14:          lblEdit.Text = "&nbsp;";
  15:          Table tbl = new Table();
  16:          tbl = (Table)e.Row.Parent;
  17:          GridViewRow myRow = new GridViewRow(0, 0, DataControlRowType.DataRow, DataControlRowState.Normal);
  18:          DataTable dt = new DataTable();
  19:          dt = (DataTable)this.dtOCCRateList;
  20:  
  21:          for (int i = 0; i < count; i++)
  22:          {
  23:              TableCell myCell = new TableCell();
  24:              // need to create the edit hyperlink in the the footer 
  25:  
  26:              if (i == 0)
  27:              {
  28:                  // leave blank
  29:                  myCell.Controls.Add(new LiteralControl(""));
  30:              }
  31:              else
  32:              {
  33:                  // create the image and hyperlink 
  34:                  HyperLink editLink = new HyperLink();
  35:                  editLink.ID = "editLink" + random;
  36:                  
  37:                  // set the image url 
  38:                  editLink.ImageUrl = "~/library/images/ico-edit.gif";
  39:  
  40:                  // set the navigate url 
  41:                  editLink.NavigateUrl = "~/Default.aspx?Id=" + dt.Rows[0][i].ToString()
  42:                      + "&PId=" + AssetId.ToString();
  43:  
  44:                  // now add this hyperlink in the table cell
  45:                  myCell.Controls.Add(editLink);
  46:                  
  47:                  // add delete 
  48:                  HyperLink delLink = new HyperLink();
  49:                  delLink.ID = "delLink" + random;
  50:                  random++;
  51:  
  52:  
  53:                  delLink.ImageUrl = "~/Library/images/delete.gif";
  54:  
  55:                  // set the navigate url
  56:                  delLink.NavigateUrl = "~/Default.aspx?Id=" + dt.Rows[0][i].ToString()
  57:                      + "&PId=" + AssetId.ToString();
  58:  
  59:                  myCell.Controls.Add(new LiteralControl("&nbsp;"));
  60:                  myCell.Controls.Add(delLink);
  61:              }
  62:  
  63:              myRow.Cells.Add(myCell);
  64:              tbl.Rows.Add(myRow);
  65:          }
  66:      }
  67:  
  68:  }
  • Currently 0 /5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Ask about quality, and then about the price
Offshore development is often synonymous with cutting costs. But the objective of cutting costs should not in any way result in selection of an outsourcing partner who might compromise on quality. studio NETSOULS is committed to provide maximum quality, at relatively low costs.

Always look for experience
Experience should be taken as one of the most important factors in choosing an outsourcing partner. Some companies can be excellent in implementing an in-house product, but can not do a similar job in working on outsourced projects. studio NETSOULS has the expertise and can provide you with the finest on your outsourced projects. More...

  • Currently 0 /5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Getting into the listing of any search engine is not a difficult task but what matters is how have you been listed in that particular site. In this article you can find tips which can help you get into good search engines along with increasing traffic.

Be frugal while spending on new domain
Buying new domain means starting everything from scratch. It might take a long time to start everything all over again. Hence don't spend too much on buying new domain rather work and revamp your existing site for better resultsMore...

  • Currently 0 /5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

A lot of times in the applications we require to pass comma separated values to the stored procedures, these values are contained in a custom object IList or IList<string> type. 

/// <summary>
/// Converts a list item property name value to comma seperated values
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="Items"></param>
/// <param name="PropertyName"></param>
/// <returns></returns>
public static string ConvertTo<T>(IList<T> Items, string PropertyName) 
{
    StringBuilder builder = new StringBuilder();
    Type entityType = typeof(T);
 
    // iterate through the property
    foreach (T Item in Items)
    {
        if (string.IsNullOrEmpty(PropertyName))
            builder.Append(Item.ToString()).Append(",");
        else 
            // get the value of the property name passed
            builder.Append(
                entityType.GetProperty(PropertyName).GetValue(Item, null).ToString()
            ).Append(",");
    }
 
    return builder.ToString().TrimEnd(new char[] { ',' });
}
  • Currently 2 /5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Sometimes you may want to pass a comma separated string as an argument to stored procedure or SQL function and parse within the procedure. This sample code shows how to parse a string based any delimiter you specify.

CREATE FUNCTION dbo.CreateInlineTable (
    @Param AS VARCHAR(7999), -- Deliminated string
    @Deliminator AS VARCHAR(10) -- Deliminator
    )   RETURNS TABLE
AS
    RETURN ( SELECT Substring(@Deliminator + @Param + @Deliminator, Number + LEN(@Deliminator), 
                    CHARINDEX(@Deliminator, @Deliminator + @Param + @Deliminator, Number + LEN(@Deliminator)) - Number - LEN(@Deliminator) ) AS PARAM
               FROM InlineNumbers Numbers
              WHERE Number <= LEN(@Deliminator + @Param + @Deliminator) - LEN(@Deliminator)
                    AND Substring(@Deliminator + @Param + @Deliminator, Number,LEN(@Deliminator)) = @Deliminator)
 
GO

More...

  • Currently 0 /5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

About Us

studio NETSOULS is a complete IT services company, offering strategy, design, development and implementation of the total solution for your web and IT initiatives. The solutions we provide, enables businesses to leverage leading edge technology to gain sustainable competitive advantages in today's marketplace.

We specialize in designing, developing and deploying the next generation of IT solutions including e-business solutions Read more...

Tags

This will be shown to users with no Flash or Javascript.

Contact Us

My status

Quote of the Day

"Do you see a man wise in his own eyes? There is more hope for a fool than for him."

- Proverbs 26:12

NutritionVista

www.NutritionVista.com

Archives


Advertisements


Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Log in