Dotnet Tutorials ,Codings & Examples: September 2009 <h1 class='display-2'> September 2009 ~ Dotnet Tutorials ,Codings & Examples</h1>

Free Asp.net UI controls

MetaBuilders WebControls Server Control Library

Here's the list of controls available 
  • AdSense Ads - Controls to show your Google AdSense ads.
  • CheckedListBox - A Listbox with checkboxes for selection
  • ComboBox - The classic type-or-choose control.
  • DataControlFields - Three fields for the GridView, BooleanField for boolean values (better than the CheckBoxField), LookupField for ID/Key data to a child datasource, and SelectorField for row selection using checkboxes or radiobuttons.
  • DialogWindow - A set of controls which make creating dialog windows a lot easier
  • DualList - move items back and forth between two listboxes to select the items
  • DynamicListBox - a base control which stores changes to its list of items
  • ExpandingButtons - hide and show a target control
  • ExpandingPanel - hide and show the content of the panel
  • FileUpload - A nicer wrapper than the builtin for basic file uploading
  • GlobalRadioButton - A radiobutton which has a page-wide, cross-namingcontainer Group property
  • Grouped Lists aka GroupedListBox and GroupedDropDownList enabled support of the html option grouping in extensions of the standard data controls.
  • ListLink - A non-visual control which helps you create parent/child relationships between list controls
  • MultiFileUpload is a nice compact UI that lets the user select more than one file to upload to the server.
  • MultiViewBar is now free and included in the library, source and all.
  • OneClick - non-visual control that helps the page developer avoid the dreaded double-button-click
  • Polling - controls and framework for showing users simple web polls. Uses a provider framework, with built-in providers for Access and Sql Server.
  • ParsingContainer - control which parses a string of server control markup at runtime
  • QueryCall - Component which maps querystring parameters to methods in the codebehind
  • RemoteWindow - Easy popup windows
  • ResizeMonitor - causes a postback on browser-resize, if you need to keep track of dimensions in your app
  • RollOverLink - the old mouse-over-out effect on images, made dead-easy
  • RuntimeTemplate - Makes it easier to create templates for controls at runtime in code
  • UpDown - the classic Windows Up/Down control for numeric entry.

Programmatically Download File from Remote Location to User Through Server

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Net;
using System.IO;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//base.OnLoad(e);
string url = string.Empty;// Request.QueryString["DownloadUrl"];
if (url == null || url.Length == 0)
{
url = "http://img444.imageshack.us/img444/6228/initialgridsq7.jpg";
}

//Initialize the input stream
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
int bufferSize = 1;

//Initialize the output stream
Response.Clear();
Response.AppendHeader("Content-Disposition:", "attachment; filename=download.jpg");
Response.AppendHeader("Content-Length", resp.ContentLength.ToString());
Response.ContentType = "application/download";

//Populate the output stream
byte[] ByteBuffer = new byte[bufferSize + 1];
MemoryStream ms = new MemoryStream(ByteBuffer, true);
Stream rs = req.GetResponse().GetResponseStream();
byte[] bytes = new byte[bufferSize + 1];
while (rs.Read(ByteBuffer, 0, ByteBuffer.Length) > 0)
{
Response.BinaryWrite(ms.ToArray());
Response.Flush();
}

//Cleanup
Response.End();
ms.Close();
ms.Dispose();
rs.Dispose();
ByteBuffer = null;
}
}

Get the index of the SelectedRow in a DataGridView

The below codes show how to do that

private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{

if (dataGridView1.SelectedRows.Count == 1)
{
txtCustcode.Text = dataGridView1.Rows[dataGridView1.SelectedRows[0].Index].Cells["CustomerCode"].Value.ToString();
}
}

Data grid view multiple checkbox selection

this shows how to use datagrid view and check boxes , and find which check box was checked


for (int i = 0; i < dgGrid.Rows.Count; i++) { GridViewRow row = dgGrid.Rows[i]; bool isChecked = ((CheckBox)row.FindControl("chkSelect")).Checked; if (isChecked) { xSideID = dgGrid.Rows[i].Cells[1].Text; } }













How to read the comma seperated values from a string asp.net C#?

string myString = "A, B, C, D";
string delimStr = " ,";
char[] delimiter = delimStr.ToCharArray();
foreach (string s in myString.Split(delimiter))
{
Response.Write (s.ToString ()+ "
");
}