This is default featured post 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Showing posts with label advance course. Show all posts
Showing posts with label advance course. Show all posts

Select Distinct From DataSet


This step-by-step article illustrates the equivalent to select distinct values from one or more column of a DataSet or DataTable
Example :

NOTE: Add the following to the top of the code window:
 

using System.Data;

//Add the following constructor code :

System.Data.DataSet ds = new System.Data.DataSet();

// Create source table

System.Data.DataTable dt = new System.Data.DataTable("MyTableName");
dt.Columns.Add("ColumnA", Type.GetType("System.Int32"));
dt.Rows.Add(1);
dt.Rows.Add(2);
dt.Rows.Add(3);
dt.Rows.Add(1);
Ds.Tables.Add(dt);
System.Data.DataView Dv = Ds.Tables["MyTableName"].DefaultView;
System.Data.DataTable DtD = Dv.ToTable(true, "ColumnA");
//DtD contains only Distinct values (1,2 and 3)

The command Dv.ToTable(true, .. help you to Select Distinct from Ds DataSet the column : "ColumnA"

Merge Similar Rows in Gridview


In this example i am going to describe how to merge GridView cells or Columns in gridview rows containing same data or content using C# and VB.NET in ASP.NET

For this i m using DataBound Event of gridview, counting total rows and then checking each cells value against value of same cell in previous row and then setting the RowSpan of cells.


For this i have created a table containing Counties ,states and respective cities and country and state cells / columns are merged in rows having same country or states.




Html source of the page look like this
<asp:GridView ID="GridView1" runat="server"      AutoGenerateColumns="False"       BorderStyle="None" BorderWidth="1px" CellPadding="4"      GridLines="Horizontal" ForeColor="Black"      Height="119px" DataSourceID="SqlDataSource1"      OnDataBound="GridView1_DataBound1">              <Columns>             <asp:BoundField DataField="Country"                              HeaderText="Country"                              SortExpression="Country" />             <asp:BoundField DataField="State"                              HeaderText="State"                              SortExpression="State" />             <asp:BoundField DataField="City"                              HeaderText="City"                              SortExpression="City" />         </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server"  ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [Country], [State], [City]                 FROM [Details] ORDER BY [State]"> </asp:SqlDataSource>

C# code behind
protected void GridView1_DataBound1(object sender, EventArgs e) {   for (int rowIndex = GridView1.Rows.Count - 2;                                       rowIndex >= 0; rowIndex--)   {     GridViewRow gvRow = GridView1.Rows[rowIndex];     GridViewRow gvPreviousRow = GridView1.Rows[rowIndex + 1];     for (int cellCount = 0; cellCount < gvRow.Cells.Count;                                                    cellCount++)     {      if (gvRow.Cells[cellCount].Text ==                              gvPreviousRow.Cells[cellCount].Text)      {        if (gvPreviousRow.Cells[cellCount].RowSpan < 2)        {          gvRow.Cells[cellCount].RowSpan = 2;        }        else        {         gvRow.Cells[cellCount].RowSpan =              gvPreviousRow.Cells[cellCount].RowSpan + 1;        }        gvPreviousRow.Cells[cellCount].Visible = false;     }    }  } } 
VB.NET code behind
Protected Sub GridView1_DataBound1            (ByVal sender As Object, ByVal e As EventArgs)  For rowIndex As Integer = GridView1.Rows.Count - 2 To 0 Step -1     Dim gvRow As GridViewRow = GridView1.Rows(rowIndex)     Dim gvPreviousRow As GridViewRow = GridView1.Rows(rowIndex + 1)     For cellCount As Integer = 0 To gvRow.Cells.Count - 1     If gvRow.Cells(cellCount).Text =                           gvPreviousRow.Cells(cellCount).Text Then     If gvPreviousRow.Cells(cellCount).RowSpan < 2 Then     gvRow.Cells(cellCount).RowSpan = 2     Else     gvRow.Cells(cellCount).RowSpan =                         gvPreviousRow.Cells(cellCount).RowSpan + 1     End If     gvPreviousRow.Cells(cellCount).Visible = False     End If     Next   Next End Sub 

--

events & workshops

.

Upcoming Events & Workshops Schedule

Event Name Event Type Date Venue URL to know more Agenda Presenter(s)
Hyderabad UG Event Free Community Event 12 Dec 2009 Saturday Microsoft Corporation (I) Pvt. Ltd.,
4th Floor, Usha Jubilee Town 36,
Plot No.8-2-293/82/A/1130/A,
Road No.36, Jubilee Hills,
Hyderabad 500 033
(near Chutney’s restaurant)

Click here

Maximizing Query Optimizer using Query & Table hints by Amit Bansal (MVP)

VS 2010 and ASP.NET 4.0 Features at a Glance by Hima Bindu Vejella (MVP)

Amit Bansal

Hima Bindu Vejell

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites