<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Datagrid &#8211; Jitendra Zaa</title>
	<atom:link href="https://www.jitendrazaa.com/blog/tag/datagrid/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.jitendrazaa.com/blog</link>
	<description>AI, Salesforce, ServiceNow &#38; Enterprise Tech Guides</description>
	<lastBuildDate>Fri, 01 Oct 2010 08:21:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
<site xmlns="com-wordpress:feed-additions:1">87744916</site><atom:link rel="search" type="application/opensearchdescription+xml" title="Search Jitendra Zaa" href="https://www.jitendrazaa.com/blog/wp-json/opensearch/1.1/document" />	<item>
		<title>DataGrid, GridView, DataList and Repeater Control in ASP.net</title>
		<link>https://www.jitendrazaa.com/blog/microsoft/net/datagrid-gridview-datalist-and-repeater-control-in-asp-net/</link>
					<comments>https://www.jitendrazaa.com/blog/microsoft/net/datagrid-gridview-datalist-and-repeater-control-in-asp-net/#comments</comments>
		
		<dc:creator><![CDATA[Jitendra]]></dc:creator>
		<pubDate>Fri, 01 Oct 2010 08:21:41 +0000</pubDate>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Datagrid]]></category>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=1178</guid>

					<description><![CDATA[DataGrid, GridView, DataList and Repeater Control in ASP.net]]></description>
										<content:encoded><![CDATA[<p>In Previous articles, i have written article about DataGrid.</p>
<p><a href="https://jitendrazaa.com/blog/microsoft/net/datagrid-example-part-1/">https://jitendrazaa.com/blog/microsoft/net/datagrid-example-part-1/</a></p>
<p><a href="https://jitendrazaa.com/blog/microsoft/net/datagrid-example-sorting-%E2%80%93-part-2/">https://jitendrazaa.com/blog/microsoft/net/datagrid-example-sorting-%E2%80%93-part-2/</a></p>
<p><a href="https://jitendrazaa.com/blog/microsoft/net/asp-net-datagrid-basic-questions/">https://jitendrazaa.com/blog/microsoft/net/asp-net-datagrid-basic-questions/</a></p>
<p><strong>DataGrid</strong>, <strong>GridView </strong>and <strong>DataList </strong>controls are derived from the WebControl class, while the <strong>Repeater </strong>control is derived from the Control class. The WebControl class contains a number of properties, such as BackColor, ForeColor, CssClass, BorderStyle and so on.<br />
In ASP .NET basically there are four kinds of the Data Presentation Controls.</p>
<ul>
<li>GridView (more options)</li>
<li>DataGrid</li>
<li>DataList</li>
<li>Repeater (less options)</li>
</ul>
<p>List of different abilities of Repeater Control, Datalist Control and GridView Control features.</p>
<p><span id="more-1178"></span></p>
<p><strong>Features of a GridView and DataGrid:</strong></p>
<ol>
<li>Displays data as a table</li>
<li>Updateable</li>
<li>Item as row</li>
<li>Control over</li>
</ol>
<ul>
<li>Alternate item</li>
<li>Header</li>
<li>Footer</li>
<li>Colors, font, borders, etc.</li>
<li>Paging</li>
</ul>
<p><strong>Features of Repeater:</strong></p>
<ol>
<li>List format</li>
<li>No default output</li>
<li>More control</li>
<li>More complexity</li>
<li>Item as row</li>
<li>Not updateable</li>
</ol>
<p><strong>Features of DataList:</strong></p>
<ol>
<li>Directional rendering</li>
<li>Good for columns</li>
<li>Item as cell</li>
<li>Alternate item</li>
<li>Updateable</li>
</ol>
<p><strong>Difference between GridView, Datagrid, DataList and Data Repeater:</strong></p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/05yye6k9.aspx" target="_blank">Please visit here, to get difference between Gridview and DataGrid.</a></li>
<li>Datagrid has paging while Datalist doesnt.</li>
<li>Datalist has a property called repeat. Direction = vertical/horizontal. (This is of great help in designing layouts). This is not there in Datagrid.</li>
<li>A repeater is used when more intimate control over html generation is required.</li>
<li>When only checkboxes/radiobuttons are repeatedly served then a checkboxlist or radiobuttonlist are used as they involve fewer overheads than a Datagrid.</li>
</ul>
<p>The Repeater repeats a layout of HTML you write, it has the least functionality of the three. DataList is the next step up from a Repeater; accept you have very little control over the HTML that the control renders. DataList is the first of the three controls that allow you Repeat-Columns horizontally or vertically. Finally, the DataGrid is the motherload. However, instead of working on a row-by-row basis, you&#8217;re working on a column-by-column basis. DataGrid caters to sorting and has basic paging for your disposal. Again you have little contro, over the HTML. NOTE: DataList and DataGrid both render as HTML tables by default.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.jitendrazaa.com/blog/microsoft/net/datagrid-gridview-datalist-and-repeater-control-in-asp-net/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1178</post-id>	</item>
		<item>
		<title>Row expand collapse using jquery and Ajax</title>
		<link>https://www.jitendrazaa.com/blog/microsoft/net/row-expand-collapse-using-jquery-and-ajax/</link>
					<comments>https://www.jitendrazaa.com/blog/microsoft/net/row-expand-collapse-using-jquery-and-ajax/#comments</comments>
		
		<dc:creator><![CDATA[Jitendra]]></dc:creator>
		<pubDate>Wed, 18 Aug 2010 20:22:55 +0000</pubDate>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Datagrid]]></category>
		<category><![CDATA[GridView]]></category>
		<category><![CDATA[JQue]]></category>
		<category><![CDATA[Web Service]]></category>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=790</guid>

					<description><![CDATA[Using JQuery and Ajax to expand and collapse the row in ASP.NET]]></description>
										<content:encoded><![CDATA[<p><strong>This article describes how to expand and collapse rows of a GridView or Table and showing data details using Jquery and Ajax<br />
</strong></p>
<p><span style="font-weight: normal;"><strong>Introduction:</strong></span></p>
<p>Now day&#8217;s , important issue with web applications is how quick a wed page is rendered  and how it is animated or  visualized</p>
<p>So for quick reply from server Ajax is the solutions and for some visualizations with server side response we mostly use jquery or javascript.<br />
I this article, for exp</p>
<p>anding , collapsing and  adding details to gridview row we are going to use AJAX to make call to server and we will visualized it using jquery.</p>
<p><span style="font-weight: normal;"><strong>Aim</strong></span></p>
<p>1. Getting details of product  by extracting details at the next to current row and before second    one.</p>
<p>2. Visualizing  the expanding of rows.</p>
<p>3. No server side postback.</p>
<p>4. Using GridView Control to bind data and simple data binding to table using scriptlet.</p>
<p><span style="font-weight: normal;"><strong>Using  Jquery Code</strong></span></p>
<p><strong>Expanding Row :</strong></p>
<p>For expanding any row, we need to create an new row  with the serverside details  and then we will add it to the next of current row</p>
<p style="text-align: center;"><img data-recalc-dims="1" fetchpriority="high" decoding="async" class="aligncenter size-medium wp-image-791" title="Ajax JQuery Row Expand Collapse" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2010/08/rowexpand-300x203.png?resize=300%2C203&#038;ssl=1" alt="Ajax JQuery Row Expand Collapse" width="300" height="203" /></p>
<pre class="brush: jscript; title: ; notranslate">
var trindex=0;	//trindex hold row index created by jquery
$(&quot;tr&quot;).click(function() {
if ($(this).find(&quot;td:first&quot;).length &gt; 0) { //check whether it is header or content row
//row index increment to assign new row id everytime
trindex++;
//create a row with td colspan 3 to show product description
var row= '&gt;&lt;td class=&quot;currRow&quot; colspan=&quot;3&quot; &gt;&lt;
div id=&quot;did&quot;&gt;&lt;img id=&quot;imagepath&quot; src=&quot;&quot;
style=&quot;height: 81px; width: 104px&quot; /&gt;  Description :&lt;
span id=&quot;des&quot;&gt;sd&lt;/span&gt;&lt;p&gt;Cost :&lt;
span id=&quot;cost&quot;&gt;sd&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;';

//adding animation to row
var newRow = $(&quot;&lt;tr id=tr&quot;+ trindex + row).animate({
height: &quot;140px&quot;,
opacity: 0.25,
}, 500);
//adding row to existing table
$(this).after(newRow);
</pre>
<h5>Collapsing  Row :</h5>
<p>At the same moment we expand any row, we collapse previous created row, so we need to remember the previous created rowIndex or it&#8217;s id.</p>
<p style="text-align: center;"><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2010/08/gridcollapsed.png?ssl=1"><img data-recalc-dims="1" decoding="async" class="aligncenter size-medium wp-image-805" title="Ajax JQuery Row Expand Collapse" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2010/08/gridcollapsed-300x282.png?resize=300%2C282&#038;ssl=1" alt="Ajax JQuery Row Expand Collapse" width="300" height="282" /></a><a href="https://jitendrazaa.com/blog/wp-content/uploads/2010/08/gridcollapsed.png"><br />
</a></p>
<pre class="brush: jscript; title: ; notranslate">
$(&quot;#&quot;+rowName).find('td').removeClass('currRow').addClass('hideRow');
$(&quot;#&quot;+rowName).animate({
    height: &quot;0px&quot;,
    opacity: 0.25,
    }, 1000, function() {
$(&quot;#&quot;+rowName).remove();&lt;/pre&gt;
&lt;h5&gt;Ajax Call to the server :&lt;/h5&gt;
For getting the full details about our shortly highlighted product, we need to make a asynchronous call to
server using AJAX. We are passing some key values to server(product Id) to extract the resultset.
&lt;pre&gt;$.ajax({
       type: &quot;POST&quot;,
       url: &quot;WebService.asmx/GetDetails&quot;,   //webserviceName/methodName
       data: &quot;{'name': '&quot; + $(this).find(&quot;td span&quot;).text() + &quot;'}&quot;,  //passing values to webservice(productid)
       contentType: &quot;application/json; charset=utf-8&quot;,
       dataType: &quot;json&quot;,
       success: function(msg) {
       //extrating response data to newly created row
       $(&quot;#tr&quot;+trindex ).find(&quot;td #did p #cost&quot;).text(msg.d.id );
       $(&quot;#tr&quot;+trindex ).find(&quot;td #did  #des&quot;).text(msg.d.order);
       $(&quot;#tr&quot;+trindex ).find(&quot;td #did #imagepath&quot;).attr('src', msg.d.order);
//$(&quot;#myImage&quot;).attr(&quot;src&quot;, &quot;path/to/newImage.jpg&quot;);
       },
       error: FailedMessage     //showing error message if failure
       });
</pre>
<h5>Using The WebService.cs</h5>
<p>Programmable application logic accessible via standard Web protocols.We are using webservice to extract data from database using jquery Ajax call.  CollectData class to hold extracted details from db.</p>
<pre class="brush: java; title: ; notranslate">
public class CollectData
{
        public string cost { get; set; }
        public string imagePath { get; set; }
        public string description { get; set; }
}
</pre>
<p>Simple queries to the database via WebMethod</p>
<pre class="brush: csharp; title: ; notranslate">
&#x5B;WebMethod()]
    public CollectData GetDetails(string name)
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings&#x5B;&quot;ConnectionString&quot;].
        ConnectionString);
        SqlCommand cmd = new SqlCommand(&quot;Select cost, imagePath, description from Products where ProductId='&quot; +
        name + &quot;'&quot;,con);
        SqlDataReader data;
        CollectData c = new CollectData();
        try
        {
            con.Open();
            data=cmd.ExecuteReader();
            if (data.Read())
            {
                c.cost= data&#x5B;0].ToString();
                c.imagePath = data&#x5B;1].ToString();
                c.description = data&#x5B;2].ToString();
                return c;
            }
            else
            {
                c.cost = &quot;N/A&quot;;
                c.imagePath = &quot;N/A&quot;;
                c.description = &quot;N/A&quot;;
                return c;
            }
        }
        catch (Exception ex)
        {
            c.cost = &quot;N/A&quot;;
            c.imagePath = &quot;N/A&quot;;
            c.description = &quot;N/A&quot;;
            return c;
        }

    }
</pre>
<p><strong>Conclusion :</strong></p>
<p>We have mixed up Jquery, Ajax, server Control(Gridview ) to get quick and visualized output. Result can be little bit change as per the browsers.</p>
<p><a href="http://www.codeproject.com/KB/aspnet/rowexpandcollapse.aspx">Uploaded on Codeproject<br />
</a><br />
<a href="http://www.box.net/shared/p0t9kzu07r">Download Demo Article</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.jitendrazaa.com/blog/microsoft/net/row-expand-collapse-using-jquery-and-ajax/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">790</post-id>	</item>
		<item>
		<title>DataGrid Sorting and Paging Example – Part 2</title>
		<link>https://www.jitendrazaa.com/blog/microsoft/net/datagrid-example-sorting-part-2/</link>
					<comments>https://www.jitendrazaa.com/blog/microsoft/net/datagrid-example-sorting-part-2/#respond</comments>
		
		<dc:creator><![CDATA[Jitendra]]></dc:creator>
		<pubDate>Tue, 18 May 2010 17:29:34 +0000</pubDate>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Datagrid]]></category>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=227</guid>

					<description><![CDATA[For Part 1, visit This URL https://jitendrazaa.com/blog/?p=191 In this part, i will show that how to Sort the Datagrid Component of ASP.NET. To sort Datagrid, we will need DataView and then assign Dataview as datasource to our Grid control. We will need to change our code of Part 1. Previously, we used DataSet as a Datasource. [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>For Part 1, visit This URL <a href="https://jitendrazaa.com/blog/?p=191">https://jitendrazaa.com/blog/?p=191</a></p>
<p>In this part, i will show that how to Sort the Datagrid Component of ASP.NET.</p>
<p>To sort Datagrid, we will need <strong><span style="color: #ff0000">DataView </span></strong>and then assign Dataview as datasource to our Grid control.</p>
<p>We will need to change our code of Part 1.</p>
<p>Previously, we used <strong>DataSet </strong>as a Datasource. This time we will use <strong>DataTable </strong>and get the DataView from DataTable using below line.</p>
<pre class="brush: csharp; title: ; notranslate">
DataView dv = dt.DefaultView; //Where dt id DataTable
</pre>
<p>So we have created a function, which will return the DataTable as shown below:</p>
<pre class="brush: csharp; title: ; notranslate">
private DataTable GetTableFromDataBase()
{
SqlConnection con = null;
SqlDataAdapter adp = null;
DataTable dt = new DataTable();
try
{
con = new SqlConnection(conString);
con.Open();
adp = new SqlDataAdapter(&quot;Select * from Employee&quot;,con);
adp.Fill(dt);
return dt;
}
catch (CustomException ex)
{
ex.logException();
}finally{
con.Close();
}
return null;
}
</pre>
<p>we will need to create the function on <strong>Sortcommand </strong>of the DataGrid.</p>
<p>The format for sorting the grid is like:</p>
<p><strong>SortExpression+&#8221;asc&#8221;</strong></p>
<p>OR</p>
<p><strong>SortExpression+&#8221;desc&#8221;</strong></p>
<p>Below is the code snap used for the sorting:</p>
<pre class="brush: csharp; title: ; notranslate">
protected void grdEmp_Sort(object source, DataGridSortCommandEventArgs e)
{
DataTable dt = GetTableFromDataBase();
DataView dv = dt.DefaultView;
string dir = string.Empty;
if (e.SortExpression.Length &gt; 0)
{
if (Session&#x5B;&quot;OldSortDir&quot;] == null)
{
Session&#x5B;&quot;OldSortDir&quot;] = e.SortExpression;
}
else
{
string oldSortExp = Session&#x5B;&quot;OldSortDir&quot;].ToString();
if (oldSortExp == &quot;asc&quot;)
{
dir = &quot;desc&quot;;
Session&#x5B;&quot;OldSortDir&quot;] = &quot;desc&quot;;
}
else
{
dir = &quot;asc&quot;;
Session&#x5B;&quot;OldSortDir&quot;] = &quot;asc&quot;;
}
}
dv.Sort = e.SortExpression+&quot;  &quot;+dir;
}
grdEmp.DataSource = dv;
grdEmp.DataBind();
}
</pre>
<p>The code for the Pagination is written below. Consider Page Size as 3.</p>
<div>
<pre class="brush: csharp; title: ; notranslate">
protected void grdEmp_Paging(object source,DataGridPageChangedEventArgs p)
{
grdEmp.CurrentPageIndex = p.NewPageIndex;
BindTable();
}
</pre>
<h1 style="text-align: center"><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2010/05/Sorting1.jpg?ssl=1"><img data-recalc-dims="1" decoding="async" class="aligncenter size-full wp-image-249" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2010/05/Sorting1.jpg?resize=289%2C252&#038;ssl=1" alt="" width="289" height="252" /></a><a href="https://jitendrazaa.com/blog/wp-content/uploads/2010/05/DataGridDemo1.zip">Download Source code</a></h1>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.jitendrazaa.com/blog/microsoft/net/datagrid-example-sorting-part-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">227</post-id>	</item>
		<item>
		<title>DataGrid Example &#8211; Part 1</title>
		<link>https://www.jitendrazaa.com/blog/microsoft/net/datagrid-example-part-1/</link>
					<comments>https://www.jitendrazaa.com/blog/microsoft/net/datagrid-example-part-1/#comments</comments>
		
		<dc:creator><![CDATA[Jitendra]]></dc:creator>
		<pubDate>Tue, 18 May 2010 13:51:06 +0000</pubDate>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Datagrid]]></category>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=191</guid>

					<description><![CDATA[For the basics of DataGrid please refer this post: https://jitendrazaa.com/blog/?p=188 In this example, i will explain the basics of DataGrid control like Theming, Databinding etc. We will start our example with creating the SQL Express database of Employee which will contain the following fields : Id, FName, LName, Email. Now create a stored procedure to [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>For the basics of DataGrid please refer this post: <a href="https://jitendrazaa.com/blog/?p=188">https://jitendrazaa.com/blog/?p=188</a></p>
<p>In this example, i will explain the basics of DataGrid control like Theming, Databinding etc.</p>
<p>We will start our example with creating the SQL Express database of Employee which will contain the following fields : Id, FName, LName, Email.</p>
<p style="text-align: center;"><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2010/05/Employee.jpg?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" class="aligncenter size-full wp-image-194" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2010/05/Employee.jpg?resize=486%2C124&#038;ssl=1" alt="" width="486" height="124" /></a></p>
<p style="text-align: left;">Now create a stored procedure to insert the data into Table.</p>
<pre class="brush: sql; title: ; notranslate">
CREATE PROCEDURE dbo.AddEmployee
@FName varchar(50),
@LName varchar(50),
@Email varchar(50)
AS
INSERT INTO Employee (FName,LName,Email) values (@FName,@LName,@Email)
</pre>
<p><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2010/05/SP.jpg?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" class="aligncenter size-full wp-image-200" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2010/05/SP.jpg?resize=252%2C235&#038;ssl=1" alt="" width="252" height="235" /></a></p>
<p>In ASPX page, write the code to input the Employee information.</p>
<pre class="brush: xml; title: ; notranslate">
First Name : &lt;asp:TextBox ID=&quot;txtFName&quot; runat=&quot;server&quot;/&gt;&lt;br /&gt;
Last Name :&lt;asp:TextBox ID=&quot;txtLName&quot; runat=&quot;server&quot;/&gt;&lt;br /&gt;
Email :&lt;asp:TextBox ID=&quot;txtEmail&quot;; runat=&quot;server&quot;/&gt;&lt;br /&gt;
&lt;asp:Button ID=&quot;btnSubmit&quot; Text=&quot;Add Record&quot; runat=&quot;server&quot; OnClick=&quot;btnSubmit_Click&quot;/&gt;
</pre>
<p>Go to the property of <strong>Employee.mdf</strong> and select connection string as shown in below image.</p>
<pre><a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2010/05/ConString.jpg?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" class="aligncenter size-full wp-image-208" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2010/05/ConString.jpg?resize=396%2C125&#038;ssl=1" alt="" width="396" height="125" /></a></pre>
<p>On the click event of the button write below function:</p>
<pre class="brush: csharp; title: ; notranslate">
string conString = @&quot;Data Source=.SQLEXPRESS;AttachDbFilename=&quot;&quot;|DataDirectory|Employee.mdf&quot;&quot;;Integrated Security=True;User Instance=True&quot;;
protected void btnSubmit_Click(object sender, EventArgs e)
{
SqlConnection con = null;
SqlCommand cmd = null;
try {
con = new SqlConnection(conString);
     con.Open();
     cmd = new SqlCommand(&quot;AddEmployee&quot;, con);
     cmd.CommandType = CommandType.StoredProcedure;
     cmd.Parameters.AddWithValue(&quot;@FName&quot;, txtFName.Text);
     cmd.Parameters.AddWithValue(&quot;@LName&quot;, txtLName.Text);
     cmd.Parameters.AddWithValue(&quot;@Email&quot;, txtEmail.Text);
     cmd.ExecuteNonQuery();
     showConfirmationMessage();
}
catch (CustomException ex) {
ex.logException();
}finally{
    con.Close();
}
}
 private void showConfirmationMessage()
{
      ClientScriptManager csMngr = Page.ClientScript;
      csMngr.RegisterStartupScript(Page.GetType(), &quot;Success&quot;, &quot;alert('Record Added succesfully');&quot;, true);
}
</pre>
<p><strong> ASPX Code for data grid</strong></p>
<div>
<pre class="brush: xml; title: ; notranslate">
&lt;asp:DataGrid ID=&quot;grdEmp&quot; runat=&quot;server&quot;&gt;
&lt;HeaderStyle CssClass=&quot;Header&quot; /&gt;
&lt;AlternatingItemStyle CssClass=&quot;AlternateItemStyle&quot; /&gt;
&lt;/asp:DataGrid&gt;
</pre>
</div>
<p>Write below code to bind the data into DataGrid.</p>
<pre class="brush: csharp; title: ; notranslate">
private void bindData()
{
SqlConnection con = null;
SqlDataAdapter adp = null;
try
{
con = new SqlConnection(conString);
con.Open();
adp = new SqlDataAdapter(&quot;Select * from Employee&quot;,con);
DataSet ds = new DataSet();
adp.Fill(ds);
grdEmp.DataSource = ds;
grdEmp.DataBind();
}
catch (CustomException ex)
{
ex.logException();
}finally{
con.Close();
}
}
</pre>
<p><strong>Final output:</strong><br />
<a href="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2010/05/output2.jpg?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" class="aligncenter size-full wp-image-223" src="https://i0.wp.com/jitendrazaa.com/blog/wp-content/uploads/2010/05/output2.jpg?resize=280%2C265&#038;ssl=1" alt="" width="280" height="265" /></a></p>
<h1 style="text-align: center;"><a href="https://jitendrazaa.com/blog/wp-content/uploads/2010/05/output2.jpg"></a><span style="color: #0000ee;"><span style="text-decoration: underline;"><a href="https://jitendrazaa.com/blog/wp-content/uploads/2010/05/DataGridDemo.zip">Download Code</a><br />
</span></span></h1>
]]></content:encoded>
					
					<wfw:commentRss>https://www.jitendrazaa.com/blog/microsoft/net/datagrid-example-part-1/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">191</post-id>	</item>
		<item>
		<title>ASP.NET DataGrid basic questions</title>
		<link>https://www.jitendrazaa.com/blog/microsoft/net/asp-net-datagrid-basic-questions/</link>
					<comments>https://www.jitendrazaa.com/blog/microsoft/net/asp-net-datagrid-basic-questions/#comments</comments>
		
		<dc:creator><![CDATA[Jitendra]]></dc:creator>
		<pubDate>Tue, 18 May 2010 13:27:50 +0000</pubDate>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Datagrid]]></category>
		<guid isPermaLink="false">http://JitendraZaa.com/blog/?p=188</guid>

					<description><![CDATA[What is datagrid? The DataGrid Web server control is a powerful tool for displaying information from a data source. It is easy to use; you can display editable data in a professional-looking grid by setting only a few properties. At the same time, the grid has a sophisticated object model that provides you with great [&#8230;]]]></description>
										<content:encoded><![CDATA[<ol>
<li><strong>What is datagrid?</strong> The DataGrid Web server control is a powerful tool for displaying information from a data source. It is easy to use; you can display editable data in a professional-looking grid by setting only a few properties. At the same time, the grid has a sophisticated object model that provides you with great flexibility in how you display the data.</li>
<li><strong>What&#8217;s the difference between the <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebUIWebControlsDataGridClassTopic.asp">System.Web.UI.WebControls.DataGrid</a> and <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWindowsFormsDataGridClassTopic.asp">System.Windows.Forms.DataGrid</a>?</strong> The Web UI control does not inherently support master-detail data structures. As with other Web server controls, it does not support two-way data binding. If you want to update data, you must write code to do this yourself. You can only edit one row at a time. It does not inherently support sorting, although it raises events you can handle in order to sort the grid contents. You can bind the Web Forms DataGrid to any object that supports the IEnumerable interface. The Web Forms DataGrid control supports paging. It is easy to customize the appearance and layout of the Web Forms DataGrid control as compared to the Windows Forms one.</li>
<li><strong>How do you customize the column content inside the datagrid?</strong> If you want to customize the content of a column, make the column a template column. Template columns work like item templates in the DataList or Repeater control, except that you are defining the layout of a column rather than a row.</li>
<li><strong>How do you apply specific formatting to the data inside the cells?</strong> You cannot specify formatting for columns generated when the grid&#8217;s AutoGenerateColumns property is set to true, only for bound or template columns. To format, set the column&#8217;s DataFormatString property to a string-formatting expression suitable for the data type of the data you are formatting.</li>
<li><strong>How do you display an editable drop-down list?</strong> Displaying a drop-down list requires a template column in the grid. Typically, the ItemTemplate contains a control such as a data-bound Label control to show the current value of a field in the record. You then add a drop-down list to the EditItemTemplate. In Visual Studio, you can add a template column in the Property builder for the grid, and then use standard template editing to remove the default TextBox control from the EditItemTemplate and drag a DropDownList control into it instead. Alternatively, you can add the template column in HTML view. After you have created the template column with the drop-down list in it, there are two tasks. The first is to populate the list. The second is to preselect the appropriate item in the list &#8220;” for example, if a book&#8217;s genre is set to &#8220;fiction,&#8221; when the drop-down list displays, you often want &#8220;fiction&#8221; to be preselected.</li>
<li><strong>How do you check whether the row data has been changed?</strong> The definitive way to determine whether a row has been dirtied is to handle the changed event for the controls in a row. For example, if your grid row contains a TextBox control, you can respond to the control&#8217;s TextChanged event. Similarly, for check boxes, you can respond to a CheckedChanged event. In the handler for these events, you maintain a list of the rows to be updated. Generally, the best strategy is to track the primary keys of the affected rows. For example, you can maintain an ArrayList object that contains the primary keys of the rows to update.</li>
</ol>
<p>You can find more questions on Datagrid at <a href="http://msdn.microsoft.com/en-us/library/Aa289519">http://msdn.microsoft.com/en-us/library/Aa289519</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.jitendrazaa.com/blog/microsoft/net/asp-net-datagrid-basic-questions/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">188</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Minified using Disk

Served from: www.jitendrazaa.com @ 2026-06-24 06:44:32 by W3 Total Cache
-->