August 14, 2004 - 01-ASP.Net

Add 2nd Line to Grid Item



I'm trying to add a custom row for each Item and Alternating 
Item that is added to my datagrid.  The idea is for each row created, 
to create another row beneath it, so I can have one cell that spans 
all the columns to display a lot of text.


Heres the code i'm using for the OnItemCreated event:


private void dgAlerts_ItemCreated(object sender,

System.Web.UI.WebControls.DataGridItemEventArgs e)
{
DataGridItem item = e.Item;
// if its not an item or alternating item, get out of here
if (item.ItemType != ListItemType.Item & item.ItemType !=
ListItemType.AlternatingItem)
return;
// we need to access the datarow to get the text, so lets get it
DataRow dataRow = ((DataRowView) item.DataItem).Row;
//now we need to create the new row, add the cell and put in some text.

DataGridItem oNewItem = new

DataGridItem(item.ItemIndex,item.DataSetIndex,item.ItemType);

TableCell oNewCell = new TableCell();
oNewItem.Cells.Add( oNewCell);
oNewCell.ColumnSpan = item.Cells.Count;
Label oFullText = new Label();
oFullText.Text = (string)
dataRow[(int)enumAlertDataGridColumns.Details];
oNewCell.Controls.Add(oFullText);

// now w need to add it to the table (is always first item in
datagrid controls) and we're done!

dgAlerts.Controls[0].Controls.Add(oNewItem);

}

If you change the event from ItemCreated to ItemDataBound
and use the same code, you will get the custom row below instead of
above your items.

<asp:DataGrid id="dgAlerts" OnItemDataBound="dgAlerts_ItemDataBound" .... />



and change the name of the private void, to dgAlerts_
ItemDataBound instead of ItemCreated.The created event has
not created your item yet, so when you append to the Controls[0]
you get it before the DataBound one. So when you change
it to the DataBound one, the Item is already created and you can
then append the new row AFTER the DataBound one.


Posted by sachauncey at 03:02 PM

August 03, 2004 - 01-ASP.Net

Dot Net Learning Guide

Link ...This SearchWebServices.com guide introduces you to .NET, explains best practices and pitfalls to avoid and provides troubleshooting help and advice. You'll find .NET articles, tutorials, tips, tools, white papers, expert advice and more to pump up your .NET know-how quickly. Drop me an e-mail to let me know what other learning guides you'd like to see on SearchWebServices. Catherine Ketcher, Editor.
TABLE OF CONTENTS
.NET Quick Start
.NET Expert Advice
.NET Migration Tips
.NET White Papers and Chapter Downloads
.NET Code Samples and Tutorials
.NET Tools and Downloads
.NET Online Resources
More Learning Guides
http://searchwebservices.techtarget.com/originalContent/0,289142,sid26_gci995718,00.html?track=NL-130&ad=488175

Posted by sachauncey at 03:39 AM

July 24, 2004 - 01-ASP.Net

dotNetD2d.com

Excellent .dot site recommended by Tom Preuss. MSD2D is a resource for the Microsoft Exchange, SharePoint, .NET and Security communities. We felt that there were two basic needs in the communities. First, tools that administrators and developers need on a daily basis such as sample code, administration tips, discussion rooms with mentors, and more. We try to keep these resources easy to find and fun to use. Second, Microsoft customers want to take full advantage of their large investment in server products. Therefore, we put together a search engine to access all the information available on products and services for these platforms. Listings of add-on products and services are FREE as is access.
http://www.msd2d.com/default_section.aspx?section=dotnet

Posted by sachauncey at 09:54 PM

May 06, 2004 - 01-ASP.Net

Using the SQLDMO COM Object to Control SQL Server from ASP.NET - Stored Procedure Creation Example

By Shannon Horn MCAD, MCSD, MCT (5/4/2004)
Most applications expose themselves as an object and Microsoft SQL Server is no exception. The functionality of SQL Server is exposed through a COM component called SQLDMO (SQL Server Distributed Management Objects). It is very easy to communicate with a COM component from within a .NET application, and you'll learn how to do so in this tutorial. Example shows creation of Stored Procedure. (From SQLJunkies)
http://www.sqljunkies.com/Tutorial/1BFBD444-DCB2-4318-A315-56BCA1D8C97D.scuk

Posted by sachauncey at 12:02 PM

November 13, 2003 - 01-ASP.Net

ASP Net Email

What is aspNetEmail? aspNetEmail is a .NET email component, also known as an assembly. It is written in 100% C# for speed and efficiency. It does not have any dependencies on CDO or any unmanaged code. aspNetEmail only requires the .NET framework to be installed on the computer.

Posted by sachauncey at 03:39 PM

October 03, 2003 - 02-VB Code

Convert String to Mixed Case


1:     Convert String to Upper/Lower Case: 

2: <%
3: Function PCase(strInput)
4:
5: Dim iPosition
6: Dim iSpace
7: Dim strOutput
8:
9: iPosition = 1
10:
11: Do While InStr(iPosition, strInput, " ", 1) <> 0
12: iSpace = InStr(iPosition, strInput, " ", 1)
13: strOutput = strOutput & UCase(Mid(strInput, iPosition, 1))
14: strOutput = strOutput &
15: LCase(Mid(strInput, iPosition + 1, iSpace - iPosition))
16: iPosition = iSpace + 1
17: Loop
18: strOutput = strOutput & UCase(Mid(strInput, iPosition, 1))
19: strOutput = strOutput & LCase(Mid(strInput, iPosition + 1))
20: PCase = strOutput
21: End Function
22: %>

Posted by sachauncey at 09:59 PM

October 01, 2003 - 01-ASP.Net

Self Configuring Form Mailer Control

A web control for emailing the content of an HTML form.

Posted by sachauncey at 01:10 PM

Ezyedit

ezyEdit - ASP Web Portal and Content Management System - RickEastes
Realtime page editing, Simple, "on-the-fly" menu construction, Modifiable permissions for users and groups, Built-in search engine optimization.
Free and includes source code.

Posted by sachauncey at 01:08 PM

August 20, 2003 - 01-ASP.Net

Redirect a Page using ASP


1:     Redirect a page using ASP:
www.mydomain.com/oldpage.asp to www.mydomain.com/newpage.asp.
Here's the code you would put in oldpage.asp:
2: <%
3:
4: Response.Status = "301 Moved Permanently"
5: Response.AddHeader "Location", "http://www.mydomain.com/newpage.asp"
6:
7: %>
8:
9:

Posted by sachauncey at 01:49 PM

August 14, 2003 - 01-ASP.Net

ASP.Net Blog Source Code - .Text

A couple of months ago I announced a .NET focus blogging site called DotNetWeblogs, which eventually became Weblogs.asp.net. Today I am happy to announce that the same code that runs weblogs.asp.net, my own blog and many other blogs in the community is now available for FREE.

The application is now called .Text.
.Text will allow you to quickly and easy create a personal weblog as well as create an entire community of blogs.

Samples can be seen at:
http://scottwater.com/blog
http://weblogs.asp.net
http://dotnetjunkies.com/weblogs

The admin can be viewed here: http://scottwater.com/dottext/gallery/1070.aspx

The binaries and source can be found here: http://www.gotdotnet.com/community/workspaces/viewuploads.aspx?id=e99fccb3-1a8c-42b5-90ee-348f6b77c407

A mailing list is also available for questions/code/etc: http://aspadvice.com/SignUp/list.aspx?l=153&c=25

Updates to .Text, will be posted here: http://scottwater.com/dottext
Thanks,
Scott

-----------------------------------------------------------
Scott Watermasysk
My Blog: http://scottwater.com/blog
Need a blog? Check out .Text
http://scottwater.com/dottext

Posted by sachauncey at 01:14 PM

July 31, 2003 - 01-ASP.Net

Upload Files With ASP.NET

UPLOAD FILES One of the nastier challenges of Web development is uploading files to the Web server for processing and storage. ASP.NET, though, provides built-in file-upload support without any need for third-party components or workarounds.

BYPASS UPLOAD SIZE LIMITS Most developers don’t realize that by default ASP.NET limits the size of uploaded files to 4 MB. -- how to tweak machine.config so users can upload whatever size of file you want. Read the article and get the code at.

Posted by sachauncey at 03:20 PM

Post Entire Form to Another Page

Q&A: POST TO A DIFFERENT FORM You want to use a form, do validation on it, but then submit the entire form to another page.

Posted by sachauncey at 03:17 PM

July 04, 2003 - 01-ASP.Net

Farpoint's Spread for Webforms

Spread for Webforms "Use FarPoint's Spread 6 to easily incorporate advanced grid and high-level spreadsheet features into your applications. You get unmatched flexibility at the cell level for maximum control over the display and entry of the data, plenty of events to respond to user changes and an impressive feature list for everything in between; including import/export capabilities, enhanced printing, 13 cell types, formulas, plus many more features you'd expect from the market-leading component. "

Posted by sachauncey at 07:42 PM

Output Names of Columns in Tables...

"...take a given recordset (which may or may not contain multiple recordsets) and output every column (with column names) and every row neatly, without having to know ANYTHING about the data returned." (from GnomeCODE submission by a reader)
1:     function outputRS(oRs)

2: { count = 1;
3: while( oRs )
4: {
5: Response.Write("<table style=
'font-size:10px;' border='1' cellspacing='0'
cellpadding='2' bordercolor='#555555'>");


6:
Response.Write("<tr bgcolor=
'#dddddd'><td colspan=" + oRs.Fields.Count + "><b>RecordSet
" + count + "</b></td></tr><tr bgcolor=#eeeeee>");

7: for( i = 0; i < oRs.Fields.Count; i++ ){
8: Response.Write("<th>" + oRs.Fields(i).Name + "</th>");
9: }
10: Response.Write("</tr>");
11: while( !oRs.EOF )
12: { Response.Write("<tr>");
13: for( i = 0; i < oRs.Fields.Count; i++ ){
14: if( new String(oRs.Fields(i)) != "undefined" )
15: { Response.Write("<td>" + oRs.Fields(i) + "</td>");
16: }
17: else
18: { Response.Write("<td> </td>");}
19: }
20: Response.Write("</tr>");
21: oRs.MoveNext();
22: }
23: Response.Write("</table><BR><BR>");
24: count++;
25: try{ oRs = oRs.NextRecordset(); }catch(e){ }
26: }
27: }
28: var oConn = Server.CreateObject("ADODB.Connection");
29: oConn.ConnectionString = your_DB_Connection_String;
30: oConn.Open();
31: var multipleRS = Server.CreateObject("ADODB.CreateRecordset");
32: multipleRS.ActiveConnection = oConn;
33: queryString = "Northwind.dbo.prReturnMultipleRecordsets";
34: multipleRS.Open(queryString);
35: outputRS(multipleRS);
36:


Posted by sachauncey at 05:28 AM

July 02, 2003 - 01-ASP.Net

Form Builder

"Introducing FormBuilder.NET, a brand new 100% web-based product that allows anyone to create ASP.NET forms visually using Internet Explorer 6. With FormBuilder.NET anyone can create ASP.NET forms without any programming experience. The FormBuilder.NET form generator automatically creates the necessary VB.NET or C# programming code used in the ASP.NET Web forms. You never have to see or program a single line of code (although you can if you'd like after the form code is generated)!"

Posted by sachauncey at 09:10 PM

June 10, 2003 - 01-ASP.Net

Adding Relationships to DataTables

Adding Relationships to DataTables We know that a DataSet is an in-memory replica of database. It can contain multiple DataTables just like a database. In addition you can also set relationship between the DataTables and navigate through the relationship. This article shows you how. By: Bipin Joshi Email : webmaster@dotnetbips.com
1:     using System;

2: using System.Data;
3: using System.Data.SqlClient;
4:
5: namespace ADONETSamples
6: {
7: class Sample
8: {
9: static void Main(string[] args)
10: {
11: //declare connection,datadapter and dataset
12: SqlConnection cnn;
13: SqlDataAdapter da;
14: DataSet ds;
15:
16: //create connection
17: cnn=new SqlConnection("connection_string_here");
18: da=new SqlDataAdapter();
19: ds=new DataSet();
20:
21: //set selectcommand property
22: da.SelectCommand=
23: new SqlCommand("select * from customers",cnn);
24:
25: //populate the dataset
26: da.Fill(ds,"customers");
27: da.SelectCommand.CommandText=
28: "select * from orders";
29: da.Fill(ds,"orders");
30:
31: //declare relationship
32: DataRelation rel=
33: new DataRelation("custorders",
34: ds.Tables[0].Columns["customerid"],
35: ds.Tables[1].Columns["customerid"]);
36: ds.Relations.Add(rel);
37:
38: //display values of customers datatable
39: foreach(DataRow r in ds.Tables[0].Rows)
40: {
41: Console.WriteLine(r["customerid"]);
42: DataRow[] childrows=r.GetChildRows("custorders");
43: foreach(DataRow cr in childrows)
44: {
45: Console.WriteLine("\t" + cr["orderid"]);
46: }
47: }
48: }
49: }
50: }
51:
52:


Posted by sachauncey at 01:51 AM

June 09, 2003 - 01-ASP.Net

ASP.Net Tools

Rich Content Rotator allows ASP.NET developers to easily implement the most common types of DHTML content rotation: news scrollers, product slideshows, feature highlights, stock tickers, and random content rotation.
Form Builder .Net FormBuilder.NET is a 100% web-based product that allows anyone to create ASP.NET forms visually using Internet Explorer 6.
Show My Code Cut and Paste your code and it will be prepared for display on an HTML page -- great for code sharing and managing you code 'snippets'


Please send tool suggestions in the comments!


Posted by sachauncey at 03:04 PM

May 30, 2003 - 01-ASP.Net

Hierarchical Data Grid +/-

Hierarchical Data and the ASP.NET DataGrid Dot Net Junkies - While there are a number of examples of showing hierarchical data using the Master/Detail record concept, what I was looking for was the ability to display collapsible child rows under those of their parents in the same grid. Something similar to the way the Winforms DataGrid works when you feed it a hierarchical dataset. Unfortunately the ASP.NET DataGrid will only accept one of the tables within a hierachical dataset in its .DataBind method. In order to work around this we need to create a single DataTable object that contains all the rows we want to show when all the nodes of the hierarchy are expanded. Along the way we will leave ourselves some clues in the DataTable rows that tell us which ones are parent nodes and which are children. Once we have created this specially formatted DataTable we can then bind it to the DataGrid, apply a few formatting functions

Posted by sachauncey at 03:47 PM

May 23, 2003 - 01-ASP.Net

April 07, 2003 - 01-ASP.Net

Create An Internal Data Table

This application saves items that the user viewed in a datagrid to an internal data table. This data table is then downloadable via excel. Cool example!
http://www.technicaltraffic.com/fmsaspx/ups_inquiry.aspx?Pass=E688

Posted by sachauncey at 03:05 PM

Loop Through Datagrid

Sub RatesDataGrid_Loop()
Dim iCount as Int32
Dim txtSaveDate as String
For iCount = 0 to RatesDataGrid.Items.Count - 1

If iCount = 1 Then
txtSaveDate = RatesDataGrid.Items(iCount).Cells(5).Text
End If

If RatesDataGrid.Items(iCount).Cells(5).Text <> txtSaveDate Then
txtSaveDate = RatesDataGrid.Items(iCount).Cells(5).Text
' RatesDataGrid.Items(iCount).Cells(5).BackColor = System.Drawing.Color.AntiqueWhite
' RatesDataGrid.Items(iCount).Cells(5).ForeColor = System.Drawing.Color.Red
RatesDataGrid.Items(iCount).Cells(5).Font.Bold = true
End If
Next
End Sub

Posted by sachauncey at 02:54 PM

Add, Update Record In An Access Database

This application was created for highschool class reunion - includes Adding and Updating in Access database. Good example of binding datareader to a form. Using Userid and Password to find a record that was already added to allow updating. Also includes validation code for fields etc.
See Application www.solvay73.org

Posted by sachauncey at 02:57 AM

April 05, 2003 - 01-ASP.Net

Display RSS News Headline Feeds using ASP or ASP.Net

Display RSS News Headline Feeds using ASP or ASP.Net

Posted by sachauncey at 03:26 AM

March 31, 2003 - 01-ASP.Net

ASP.Net Controls

Please send control suggestions in the comments for this entry!

ASP Net Menu
ASP.Net Grid from Infragistics
RSS - Sharp Reader Written in .Net

Posted by sachauncey at 06:58 PM

ASP.Net Samples

Please send sample suggestions in the comments for this entry!

A Collection of Datagrid Articles - More extensive than this one!
Creating Master-Detail Listings using ASP.NET controls
Persistant and Bidirectional Sorting In DataGrid
Downloadable DataList samples for beginners
Creating DataGrid Programmatically
Building a Master/Detail DataGrid for Database Inserts
Recalculating Column Values in DataGrid
Display DataGrid in small screen area without using Paging
Creating DataGrid Templated Columns Dynamically - Part I
Creating DataGrid Templated Columns Dynamically - Part II
Displaying Two DataTables In One DatGrid
Displaying Images from SQL Server database in DataGrid
Display Conditional Data In DataGrid Column
Confirming Deletes in ASP.NET DataGrid
Adding Paging Functionality To DataList
Alphabetical Paging in DataGrid
Quickly Adding A New Row In DataGrid
Custom Paging In DataGrid
Sorting Template Columns of ASP.NET DataGrid
Using Radio Buttons To Select DataGrid Row
File Upload Using ASP.Net
Inserting A Record Into a Dataset
Common ASP.NET Code Techniques - Collections, Arrays, Hash Tables etc.
Export Datasets to Excel
Top 10 Questions About the Datagrid Server Control
Windows Forms versus Web Forms DataGrid Controls, Controlling Column Width, Height, and Alignment, Customizing Column Layout in Display and Edit Mode, Formatting Dates, Currency, and Other Data, Showing and Hiding Columns Dynamically, Adding Columns Dynamically, Adding New Records to a Data Source Using the DataGrid Control, Displaying a Drop-Down List in Edit Mode, Selecting Multiple Items Using a Check Box (Hotmail Model),
Editing Multiple Rows At Once, Selecting Rows by Clicking Anywhere
Ask the DotNetJunkies How do I add a DropDownList to a DataGrid EditItemTemplate
File Upload with ASP.Net
Nesting Server Controls
Working with Datagrid Templates
Loop Through a Datagrid (Display Hierarchical Data)
Sticky Table Headers - Stay Put When Scrolling
DataGrid and Checkboxes

Posted by sachauncey at 01:42 PM

March 19, 2003 - 01-ASP.Net

Return Multiple Resultsets with DataReader


1:     Dim objConn As SqlConnection

2: Dim objCmd As SqlCommand
3: Dim dataReader As SqlDataReader
4: Dim strSql As String
5: Dim txtCarrier as String
6: Dim txtFromPort as String
7: Dim txtToPort as String
8: Dim txtContainer as String
9: Dim txtProduct as String
10:
11: Sub Page_Load(Source As Object, E As EventArgs)
12:
13: 'SQL connection.
14: objConn = New SqlConnection("Data Source=xxxxxxx;" _
15: & "Initial Catalog=xxxxxxxx;User Id=sa;Password=xxxxxx;" _
16: & "Connect Timeout=15;Network Library=dbmssocn;")
17:
18: If Not Page.IsPostBack Then
19: LoadCombos
20: End If
21:
22: End Sub
23:
24: Sub LoadCombos()
25:
26: strSql = "SELECT SP_Key, SP_Name FROM tbl_Service_Provider_Codes WHERE SP_Type = 'C' ORDER BY SP_Name;" _
27: & "SELECT tbl_Port_Codes.Port_Key, tbl_Country_Codes.Country_Name + '-' + tbl_Port_Codes.Port_Name as Port FROM tbl_Port_Codes INNER JOIN tbl_Country_Codes ON tbl_Port_Codes.Port_Country_Key = tbl_Country_Codes.Country_Key Where tbl_Port_Codes.Port_Mode = 'O' ORDER BY Port;" _
28: & "SELECT tbl_Port_Codes.Port_Key, tbl_Country_Codes.Country_Name + '-' + tbl_Port_Codes.Port_Name as Port FROM tbl_Port_Codes INNER JOIN tbl_Country_Codes ON tbl_Port_Codes.Port_Country_Key = tbl_Country_Codes.Country_Key Where tbl_Port_Codes.Port_Mode = 'O' ORDER BY Port;" _
29: & "SELECT Product_Key, Product_Name FROM tbl_Product_Codes ORDER BY Product_Name;" _
30: & "SELECT Container_Key, Container_Name FROM tbl_Container_Codes ORDER BY Container_Name;"
31:
32:
33: objCmd = New SqlCommand(strSql, objConn)
34: Try
35: objConn.Open()
36: dataReader = objCmd.ExecuteReader()
37: 'Carriers
38: With ddlCarriers
39: .DataSource = dataReader
40: .DataTextField = "SP_Name"
41: .DataValueField = "SP_Key"
42: .DataBind()
43: End With
44: dataReader.NextResult()
45: 'From PortCodes
46: With ddlFromPorts
47: .DataSource = dataReader
48: .DataTextField = "Port"
49: .DataValueField = "Port_Key"
50: .DataBind()
51: End With
52: 'To PortCodes
53: dataReader.NextResult()
54: With ddlToPorts
55: .DataSource = dataReader
56: .DataTextField = "Port"
57: .DataValueField = "Port_Key"
58: .DataBind()
59: End With
60: 'Products
61: dataReader.NextResult()
62: With ddlProducts
63: .DataSource = dataReader
64: .DataTextField = "Product_Name"
65: .DataValueField = "Product_Key"
66: .DataBind()
67: End With
68: 'Container
69: dataReader.NextResult()
70: With ddlContainers
71: .DataSource = dataReader
72: .DataTextField = "Container_Name"
73: .DataValueField = "Container_Key"
74: .DataBind()
75: End With
76: Catch exc As Exception
77: Response.Write(exc)
78: Finally
79: If Not dataReader Is Nothing Then
80: dataReader.Close()
81: End If
82: objCmd = Nothing
83: If objConn.State = ConnectionState.Open Then
84: objConn.Close()
85: End If
86: objConn.Dispose()
87: End Try
88:
89: End Sub


Posted by sachauncey at 08:01 PM