C# : Tutorial of Asp.net with c# and example

Example and code about windows application, web application, SQL, C#, WPF etc which is helpful to developer and programer.

Search This Blog

Asp.Net: How to make Button make as default button in asp.net?

♠ Posted by uvesh in



How to make button as default button?

 
Your Button put in panel and give button id in DefaultButton property of panel. most of people think and find Button's property to make it default but actually here asp panel is require and set panel's property DefaultButtton="Here write button id which you want to make default"  .


<asp:Panel ID="pnl1" runat="server" DefaultButton ="Button1">
  <asp:Button ID="Button1" runat="server" text="Click Me!" />
   <asp:Button ID="Button2" runat="server" text="PushMe" />
</asp:Panel>


Here  your default button is  Button1
Using this functionality no need to click by button just enter and click event of default button is occures.

Here other property of button control is text which text you can see on button like as below image :



 

Improve Your Answer as comment below.
If our post is useful please share and comment on our post for more post and detail Visit :

http://aspdotnethelpmaster.blogspot.in/

 

SQL: 'IN' Query example in SQL with c#

♠ Posted by uvesh in


Example of 'in Query' in SQL Server Management studio 2008 with C#

Whenever you fire where condition in SQL you need give some value in where condition some time you need to only assign only single value or some times you need to assign number of value in where condition that time IN Query is most useful. 

there may be in database comma sepreted  value in single field and you need to right in Where condition that time IN Query is most useful to you.

For Example In below code First make one string using foreach loop from datatable which is comma sepreted and ten last statement contain SQL Query which contain Where condition. 

here Where condition on empid field which compare number of empid at a time which is comma sepreted.


string var = "";
foreach (DataRow row in table.Rows)
{
var += row["emp_no"].ToString() + ",";
}
if (var.EndsWith(","))
{
var = var.Trim().Substring(0, var.Trim().Length - 1);
//do sql connection
string value1 = sql.GetSingleValue("select empuniqid from Empmaster where empid in ( " + var + " ) ");



Improve Your Answer as comment below.
If our post is useful please share and comment on our post for more post and detail Visit :

http://aspdotnethelpmaster.blogspot.in/

ASP.Net: How to use ajax calender extender control with demo code in C#

♠ Posted by uvesh in

ASP.NET AJAX Calender Extender use for the get selected date in particular control like textbox,Image button or button.


Step 1: First of all you need download ajax control toolkit from http://ajaxcontroltoolkit.codeplex.com/ and add in your project Bin Folder by right click on Bin  Folder And select add reference.
then add following code in web.config file of asp.net project or website:
<pages>
      <controls>
                <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagprifix="ajaxToolkit" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit"/>
      </controls>
    </pages>
OR
You can add it on page like as follow:
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
Step 2: Add ToolScriptManager as follow:


<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</ajaxToolkit:ToolkitScriptManager>

Step 2:  Add One text box on your page as follow:
<asp:TextBox ID="txtDate" runat="server" ReadOnly="true"></asp:TextBox>
 
Step 3: Add One Image Button on your page as follow:

<asp:ImageButton ID="imgPopup" ImageUrl="images/calendar.png" ImageAlign="Bottom"
    runat="server" />
 
Step 4:  Now add Ajax calendarextender tag as follow:
   
<ajaxToolkit:CalendarExtender ID="Calendar1" PopupButtonID="imgPopup" runat="server" TargetControlID="txtDate"
    Format="dd/MM/yyyy">
</ajaxToolkit:CalendarExtender>

OutPut As Follwo:















Improve Your Answer as comment below.
If our post is useful please share and comment on our post for more post and detail Visit :

http://aspdotnethelpmaster.blogspot.in/
 

how to use ispostback proerty in asp.net with example

♠ Posted by uvesh in

Use of IsPostBack property and its example


It is not method.
It is the property in the System.Web.UI namespace.
It should be Page.IsPostBack.

IsPostback property is used to Gets a value that indicates whether the page is being rendered for the first time or is being loaded in response to a postback.

This IsPostBack property returns the boolean value either True or False.

The following example shows how to test the value of the IsPostBack property when the page is loaded
in order to determine whether the page is being rendered for the first time or is responding to a postback.
If the page is being rendered for the first time, the code calls the  excuteonpageload() method.

private void Page_Load()
{
    if (!IsPostBack)
    {
        // Validate initially to force asterisks
        // to appear before the first roundtrip.
        excuteonpageload();
    }
}

After render the web page, if you do any post back then it will be called. In the web page,
we used to check whether its loaded first time or posted back.
Because we do not want to bind the concrete controls to rebind again.
It will increase the performance of the web application.



Improve Your Answer as comment below.
If our post is useful please share and comment on our post for more post and detail Visit :

http://aspdotnethelpmaster.blogspot.in/

use of Gridview control in asp.net and example of gridview

♠ Posted by uvesh in


What is gridview conntrol in asp.net and its use ?

  • gridview is a very useful control in asp.net. 
  • gridview is mainly uses for display data in tabularform.
  • it also can edit, update, insert data. 
  • this can help you to display and format tabular data very easy and fastest way.
  •  we can format the gridview's nearly all parts as example header, row, alternate row, paging etc. 
  • even we can place insert,edit,delete button for each row. 

Example of Grid view control using .aspx page in asp.net as follow:


In this simple example we create a default formatted gridview. we also create a sqldatasource control populate the data source by a simple database query.


<script runat="server">  
  
</script>  
  
<body>  
    <form id="form1" runat="server">  
    <div>  
      
        <asp:GridView ID="GridView" runat="server" AllowPaging="True"   
            AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ClientId"   
            DataSourceID="SqlDataSource_demo">  
            <Columns>  
                <asp:BoundField DataField="ClientId" HeaderText="ClientId" ReadOnly="True"   
                    SortExpression="ClientId" />  
                <asp:BoundField DataField="CompanyName" HeaderText="CompanyName"   
                    SortExpression="CompanyName" />  
                <asp:BoundField DataField="ContactName" HeaderText="ContactName"   
                    SortExpression="ContactName" />  
                
                <asp:BoundField DataField="Address" HeaderText="Address"   
                    SortExpression="Address" />  
                <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />  
              <asp:BoundField DataField="PinCode" HeaderText="PinCode"   
                    SortExpression="PinCode" />
<asp:BoundField DataField="State" HeaderText="State"   
                    SortExpression="State" />    
                <asp:BoundField DataField="Country" HeaderText="Country"   
                    SortExpression="Country" />  
                <asp:BoundField DataField="Moble" HeaderText="Moble" SortExpression="Moble" />
                <asp:BoundField DataField="Landline" HeaderText="Landline" SortExpression="Landline" />  
            </Columns>  
        </asp:GridView>  
        <asp:SqlDataSource ID="SqlDataSource_demo" runat="server"   
            ConnectionString="<%$ ConnectionStrings:AppConnectionString1 %>"   
            SelectCommand="SELECT * FROM [Client]"></asp:SqlDataSource>  
      
    </div>  
    </form>  
</body>  
</html>




Improve Your Answer as comment below.
If our post is useful please share and comment on our post for more post and detail Visit :

http://aspdotnethelpmaster.blogspot.in/

List of event in page life cycle of asp.net

♠ Posted by uvesh in


Page life cycle of asp.net




A list of events in the ASP.NET page life cycle.



1. PreInit:

Check for the IsPostBack property to determine whether this is the first time the page is being processed.
Create dynamic controls.
or reCreate dynamic controls.
Set master page dynamically.
Set the Theme property dynamically.
Read profile property values.
Set profile property values.

If Request is postback:

The values of the controls have not yet been restored from view state.
If you set control property at this stage, its value might be overwritten in the next event.

2. Init:

In the Init event of the individual controls occurs first, later the Init event of the Page takes place.
This event is used to initialize control properties.

3. InitComplete:

Tracking of the ViewState is turned on in this event.
Any changes made to the ViewState in this event are persisted even after the next postback.
PreLoad:

This event processes the postback data that is included with the request.

4. Load:

In this event the Page object calls the OnLoad method on the Page object itself, later the OnLoad method of the controls is called.
Thus Load event of the individual controls occurs after the Load event of the page.

5. ControlEvents:

This event is used to handle specific control events such as a Button control’s Click event or a TextBox control’s TextChanged event.
In case of postback:

If the page contains validator controls, the Page.IsValid property and the validation of the controls takes place before the firing of individual control events.
LoadComplete:

This event occurs after the event handling stage.
This event is used for tasks such as loading all other controls on the page.

6. PreRender:

In this event the PreRender event of the page is called first and later for the child control.
Usage:

This method is used to make final changes to the controls on the page like assigning the DataSourceId and calling the DataBind method.

7. PreRenderComplete:

This event is raised after each control's PreRender property is completed.

8. SaveStateComplete:

This is raised after the control state and view state have been saved for the page and for all controls.

9. RenderComplete:

The page object calls this method on each control which is present on the page.
This method writes the control’s markup to send it to the browser.

10. Unload:

This event is raised for each control and then for the Page object.

11. Usage:

Use this event in controls for final cleanup work, such as closing open database connections, closing open files, etc.




Improve Your Answer as comment below.
If our post is useful please share and comment on our post for more post and detail Visit :

http://aspdotnethelpmaster.blogspot.in/

Concept of MVC (Model View Controller) in asp.net

♠ Posted by uvesh in

Definition of MVC(Model View Controller) in asp.net



MVC is one of three ASP.NET programming models. MVC is a framework for building web applications using a MVC (Model View Controller) design: The Model represents the application core (for instance a list of database records).

ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that enables a clean separation of concerns and that gives you full control over markup for enjoyable, agile development. ASP.NET MVC includes many features that enable fast.


Models-: Model objects are the parts of the application that implement the logic for the applications data domain. Often, model objects retrieve and store model state in a database. Such as a Product object might retrieve information from a database, operate on it, and then write updated information back to a Products table in SQL Server.


In small applications, the model is often a conceptual separation instead of a physical one. For example, if the application only reads a data set and sends it to the view, the application does not have a physical model layer and associated classes. In that case, the data set takes on the role of a model object.

Views-: Views are the components that display the applications user interface. Typically, this user interface is created from the model data. An example would be an edit view of a Products table that displays text boxes, drop-down lists, and check boxes based on the current state of a Products object.


Controllers-: Controllers are the components that handle user interaction, work with the model, and ultimately select a view to render that displays UI. In an MVC application, the view only displays information; the controller handles and responds to user input and interaction. For example, the controller handles query-string values, and passes these values to the model, which in turn queries the database by using the values.


Improve Your Answer as comment below.
If our post is useful please share and comment on our post for more post and detail Visit :

http://aspdotnethelpmaster.blogspot.in/

C# : Insert data in sql database using stored Procedure in asp.net

♠ Posted by uvesh in ,

How to insert data in sql server database using asp.net and c#



First of all require to Create database, create connection, and then Following code help full to you



string constring = "Data Source=server name here.;Initial Catalog=DatabaseName;Integrated Security=True";

SqlConnection dbCon = new SqlConnection(constring);

SqlCommand sqlCmd;

DataTable dbTbl;

sqlCmd = new SqlCommand();

dbCon.Open();

sqlCmd.CommandType = CommandType.StoredProcedure;

sqlCmd.Connection = constring;


sqlCmd.CommandText = ("INSERT INTO TABLE NAME VALUES(jack,newyork,U.S.A) ");

sqlCmd.ExecuteNonQuery()

dbCon.Close();

Example of Above code

string constring = "Data Source=localhost.;Initial Catalog=Shop;Integrated Security=True";

SqlConnection dbCon = new SqlConnection(constring);

SqlCommand sqlCmd;

DataTable dbTbl;

sqlCmd = new SqlCommand();

dbCon.Open();

sqlCmd.CommandType = CommandType.StoredProcedure;

sqlCmd.Connection = constring;


sqlCmd.CommandText = ("INSERT INTO EMP  VALUES(jack,newyork,U.S.A) ");

sqlCmd.ExecuteNonQuery();

dbCon.Close();


Improve Your Answer as comment below.

If our post is useful please share and comment on our post for more post and detail Visit :


http://aspdotnethelpmaster.blogspot.in/

Asp.Net TextBox Control example with its main property


Example of Basic Textbox and its property in asp.net

The TextBox control is used to create a text box where the user can input text or symbol.


A basic TextBox as follow:


<asp:TextBox id="textbox1" runat="server" />
<br /><br />
A basic TextBox: 

A password TextBox as follow:


<asp:TextBox id="textbox2" TextMode="password" runat="server" />
<br /><br />
A password TextBox: 

A TextBox with text as follow:

<asp:TextBox id="textbox3" Text="Hello World!" runat="server" />
<br /><br />

A TextBox with text: 

A multiline TextBox as follow:

<asp:TextBox id="textbox4" TextMode="multiline" runat="server" />
<br /><br />

A TextBox with height as follow:

<asp:TextBox id="textbox5" rows="4" TextMode="multiline"
runat="server" />
<br /><br />

A multiline TextBox: 

A TextBox with width as follow:

<asp:TextBox id="textbox6" columns="20" runat="server" />

A TextBox with height: 




Improve Your Answer as comment below.

If our post is useful please share and comment on our post for more post and detail Visit :


http://aspdotnethelpmaster.blogspot.in/

How do i bind data in asp.net textbox control run time and design time and some important property of textbox

♠ Posted by uvesh in ,

Bind data in text box in code behind and in aspx means design time


Bind data in text box at design time as follow:


<asp:TextBox id="textbox1" Text="Hello World!" runat="server" />

its display: Hello World!


Bind data in text box at codeing  time or in code behind page as follow:


textbox1.text = "Hello World!"

it display as :"Hello World!"


Bind data in text box at codeing from database or data source as follow:


textbox1.text = datarow["field name of datatable or database"];

Example : textbox1.text = datarow["firstname"];

Important Property of Asp.Net Textbox control as follow:

AccessKey:specify a key that navigates to the TextBox control.

           
Example :
 

<asp:Textbox ID="txt" runat="server" AccessKey="T"  Text="<u>T</u>ext Here:"> </asp:Textbox>
here click on Alt+T you can access this textbox.

AutoCompleteType: associate an AutoComplete class with the TextBox control.


<asp:TextBox id="username" AutoCompleteType="Type" runat="server"/>

 Here Type is different type of autocomplete type such as
FirstName, LastName, MiddleName, None, Office, Email etc you need to write instead of Type any of this many more 

AutoPostBack:post the form containing the TextBox back to the server automatically when the contents of the TextBox is changed.

True if an automatic postback occurs when the TextBox control loses focus; otherwise, false. The default is false.
Example : <asp:Textbox id="Searchtxt" AutoPostBack="True" runat="server"/>

Columns:specify the number of columns to display.

Example : <asp:Textbox id="Searchtxt" Columns="3" runat="server"/>

Enabled:disable the text box.

Example : <asp:Textbox id="Searchtxt" Enabled="True" runat="server"/>

MaxLength:specify the maximum length of data that a user can enter in a text box (does not work when TextMode is set to Multiline).

Example : <asp:Textbox id="Searchtxt" maxlength="50" runat="server"/> 

ReadOnly: prevent users from changing the text in a text box.

Example : <asp:Textbox id="Searchtxt" ReadOnly="True" text="can't change" runat="server"/> 

Rows:specify the number of rows to display.

Example : <asp:Textbox id="Searchtxt" Rows="5" runat="server"/> 

TabIndex: specify the tab order of the text box.

Example : <asp:Textbox id="Searchtxt" TabIndex="5" runat="server"/> 

Wrap:specify whether text word-wraps when the TextMode is set to Multiline.

Example : <asp:Textbox id="Searchtxt" textmode="multiline" Wrap="True" runat="server"/>

Focus: set the initial form focus to the text box.

Example : <asp:Textbox id="Searchtxt" Focus="True" runat="server"/>




Improve Your Answer as comment below.

If our post is useful please share and comment on our post for more post and detail Visit :


http://aspdotnethelpmaster.blogspot.in/

Data bind in asp.net using Listview control instead of eval method

♠ Posted by uvesh in ,

Use and Importance of List View Control 


Data Binding in aps.net without Eval Bind method

The use of the Eval and Bind methods can be complicated.

This method with Data-Binding Expressions are GridView,, Repeater, and ListView. These are actually Data-Bound controls which can be bound to Data Source controls such as SqlDataSource.

Here ways to reduce the complexity of usage of the Eval method.

example of Without eval. If you are using eval method to bind data for large web applications with millions of clicks per minute, the Eval method isn’t really the perfect solution. There is everything hard-coded in HTML.

In this example, we are not going to use the Eval or Bind methods, nor are we are going to use Data Source controls. We are going to do everything from the server side.

ListView : This control has some very important event that we are going to heavily manipulate - ItemDataBound. It has templates, e.g., ItemTemplate and EditItemTemplate. Our example is going to bind the data from a DataSet, edit this data, and update it.

protected void Page_Load(object sender, EventArgs e)
{
    if (ListView.EditItem == null)
    {
        ListView.DataSource = LoadDataSet();
        ListView.DataBind();
    }
}


We are take Label controls in the ItemTemplate and TextBox controls in the EditItemTemplate. In the “edit mode”, every Label is going to be switched with a TextBox.




protected void Item_ListView_ItemDataBound(object sender, ListViewItemEventArgs e)
{

    ListViewDataItem dataItem = (ListViewDataItem)e.Item;
    DataRowView datarow_view = (DataRowView)dataItem.DataItem;
       
    if (ProductsListView.EditItem == null)
    {

        Label organization = (Label)e.Item.FindControl("organization");
        organization.Text = datarow_view["organization"].ToString();

        Label city = (Label)e.Item.FindControl("City");
        city.Text = datarow_view["City"].ToString();

        Label clientId = (Label)e.Item.FindControl("clientId");
        clientId.Text = datarow_view["clientId"].ToString();

    }

Improve Your Answer as comment below.

If our post is useful please share and comment on our post for more post and detail Visit :


http://aspdotnethelpmaster.blogspot.in/

How to bind data in checkboxlist control of asp.net? and property of checkboxlist control

♠ Posted by uvesh in ,

Checkboxlist: Creates a multi selection check box group that can be dynamically created by binding the control to a data source.

Data bind in CheckBoxList in asp.net following code for aspx page

 <asp:CheckBoxList ID="CheckBoxList1" runat="server"
   DataSourceID="SqlDataSource1" DataTextField="text" DataValueField="text">
  </asp:CheckBoxList>


Data Bind in CheckBoxList in asp.net following Code write in Code behind page



if (!IsPostback)
{

CheckBoxList1.DataSource = dataset/datatable/datasource;
CheckBoxList1.DataTextField = "tex";
CheckBoxList1.DataValueField = "text";
CheckBoxList1.DataBind();

}

Use Full Property pf asp ListBox control as follow:

AppendDataBoundItems, AutoPostBack, CausesValidation, DataTextField, DataTextFormatString, DataValueField, Items, runat, SelectedIndex, SelectedItem, SelectedValue, TagKey, Text, ValidationGroup, OnSelectedIndexChanged

Improve Your Answer as comment below.

If our post is useful please share and comment on our post for more post and detail Visit :


http://aspdotnethelpmaster.blogspot.in/

C#: How to bind radio buttonlist in asp other control like checkboxlist,listbox,dropdownlist

♠ Posted by uvesh in

asp.net controls which support data binding:

  • asp:CheckBoxList
  • asp:RadioButtonList
  • asp:Listbox
  • asp:DropDownList

The selectable items in each of the above controls are usually defined by one or more asp:ListItem controls

<html>
<body>

<form runat="server">
<asp:RadioButtonList id="countrylist" runat="server">
<asp:ListItem value="S" text="Sunday" />
<asp:ListItem value="M" text="Monday " />
<asp:ListItem value="T" text="Tuesday " />
<asp:ListItem value="W" text="Wednesday" />
<asp:ListItem value="Th" text="Thersday" />
<asp:ListItem value="F" text="Friday " />
<asp:ListItem value="S" text="Saturday " />
</asp:RadioButtonList>
</form>
</body>
</html>


Improve Your Answer as comment below.

If our post is useful please share and comment on our post for more post and detail Visit :


http://aspdotnethelpmaster.blogspot.in/

Asp.net : What is ListView in asp.net and how it is use for binding Data?

♠ Posted by uvesh in

Definition of ListView and use of List view


ASP.NET have a new data binding control named the ListView. ASP.NET already has a number of  data bind controls. It may be more then 10 databinding control. ListView literally replace all other data binding controls in ASP.NET.

 ListView Control easy very easy for databinding. ListView control makes data binding easier than previous controls. It has default included styling with CSS, more flexible paging, and sorting, inserting, deleting, and updating features and many more.

The ASP.NET ListView control enables us to bind to data items that are returned from a data source and present  them to end user.

You can display data in pages so there is also load balancing at end user even there is large amount of data because of paging user no need wait for load data.
You can display items individually, or you can group them.

The ListView control displays data in a format that you define by using templates and styles.
It is useful for data in any repeating structure, similar to the DataList and Repeater controls.

However, unlike those controls, with the ListView control you can enable users to edit, insert, and delete data,and to sort and page data, all without code.


Improve Your Answer as comment below.

If our post is useful please share and comment on our post for more post and detail Visit :


http://aspdotnethelpmaster.blogspot.in/

C# : comment in asp.net or c sharp and use of it and short cut key for do comment

♠ Posted by uvesh in ,

How to comment code in asp.net?


Comment code in asp.net page as follow:


<%write comment here%>

Shortcut key for do comment in aspx page in asp.net as follow:


CTRL + K, CTRL + C For Make comment selected text.

CTRL + K,CTRL + U For Remove  comment of selected text.

Do comment in aspx.cs(code behind) page in asp.net as follow:

//comment  can write here

advantage of comment or use of comment as follow:


  • Removed at compile-time
  • Doesn't increase size of markup
  • You can even optimize with them







Improve Your Answer as comment below.

If our post is useful please share and comment on our post for more post and detail Visit :


http://aspdotnethelpmaster.blogspot.in/

C#: how to bind data in repeater control in asp.net? and example of repeater with c# code


What is Repeater Control?



Repeater Control is a control of asp.net which is used to display the data which is daynamic and repeatedly change collection of record


How to work repeater control of asp.net?

The Repeater control works by looping through the records in your data source and then repeating the rendering of
it’s templates called item template.
Repeater control contains different types of template fields those are

1) itemTemplate
2) AlternatingitemTemplate
3) HeaderTemplate
4) FooterTemplate
5) SeperatorTemplate


what is use of ItemTemplate in repeater control of asp.net?

ItemTemplate defines how the each item is rendered from dataBase collection.


what is use of AlternatingItemTemplate in repeater control of asp.net?


AlternatingItemTemplates is used to change the background color and styles of AlternatingItems in DataBase collection


what is use of HeaderTemplate in repeater control of asp.net?


HeaderTemplate is used to display Header text for DataSource collection and apply different styles for header text.


what is use of FooterTemplate in repeater control of asp.net?

FooterTemplate is used to display footer element for Data collection


what is use of SeparatorTemplate in repeater control of asp.net?

SeparatorTemplate will determine separator element which separates each Item in Item collection. Usually, SeparateTemplate will be <br> html tag or <hr> html tag.


How to Design of repeater control?


<asp:Repeater ID="Reptrsexample" runat="server">
<HeaderTemplate>
<table >
<tr >
<td colspan="2">
<b>header</b>
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr >
<td>
<table>
<tr>
<td>
data:
<asp:Label ID="lblSubject" runat="server" Text='<%#Eval("field_name") %>' Font-Bold="true"/>
</td>
</tr>
</table>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</div>


How to Bind data in repeater by use of C#?

Import following name space

using System;
using System.Data;
using System.Data.SqlClient;


protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
BindRepeaterData();
}
}


protected void BindRepeaterData()
{
con.Open();
SqlCommand cmd = new SqlCommand("select * from Repeater_Table", con);
DataSet ds = new DataSet();
SqlDataAdapter dadp = new SqlDataAdapter(cmd);
dadp.Fill(ds);
Reptrsexample.DataSource = ds;
Reptrsexample.DataBind();
con.Close();
}



Improve Your Answer as comment below.

If our post is useful please share and comment on our post for more post and detail Visit :


http://aspdotnethelpmaster.blogspot.in/
 

Asp.Net Master Page Tutorial

♠ Posted by uvesh in ,


What Is Master Page in Asp.Net and How To create master page in Asp.Net



What Is Asp.Net master page?


In Web site development with Asp.Net, the master page is a feature that enables you to define common structure and interface markup elements for your web Site, including headers, footers, style definitions, or navigation bars. The master page can be shared by any of the pages in your Web site, called the content page, and removes need to duplicate code for shared elements within your Web site.

For instance, if you would like to display a standard header and footer in each page of your website, then you can generate the standard header and footer in a Master Page. That’s how powerful a master page is to handle multiple forms and is easier to maintain throughout what the website looks like. Take note, the ID attribute uniquely identifies the placeholder, allowing you to put more than one placeholder in a master page.

How to Create Master Page in Asp.Net?


To start - open your Visual Studio 2008, File and choose New Web Site, choose C#.

Choose ASP.NET Empty Web Site. Make the default File System; you can change the file directory of your file. Just simply browse and name your folder where your file is being saved and click Ok.





Improve Your Answer as comment below.

If our post is useful please share and comment on our post for more post and detail Visit :


http://aspdotnethelpmaster.blogspot.in/

User Control:How do i create user define control in asp.net c#

♠ Posted by uvesh in


How use Userdefine Control in Asp.Net



For create asp.net user define control using c# following step perform

Definition of UserControl in Asp.Net :

In Asp.Net Web server controls , you can create your own custom, reusable controls using following step. These controls are called user controls.

A user control is a kind of composite control that works much like an ASP.NET other server control . you can add existing Web server controls and markup to a user control, and define properties and methods for the control. You can then embed them in ASP.NET Web pages like same as other server control.




Start Visual Studio 2005.

File -New-Project Type Visual C#.



Step 1: Adding a user control to the web site

Adding a user control to your solution is real simple. You just have to right click your solution and click Add New Item; then from the dialog window click Web User Control and name the control YourControl.ascx.




Step 2: Adding the ASP.NET controls to YOURControl.ascx

As mentioned earlier this user control will merely consist of a GridView and a SqlDataSource ASP.NET server controls.
Before we go ahead and add our controls to the user control, notice that the Page directive is not used for our user control, and that it has been replaced with the Control directive.





If our post is useful please share and comment on our post for more post and detail Visit :

http://aspdotnethelpmaster.blogspot.in/

SQL Connection: Very Easy Code For SQL Connection by C# and Asp.Net

♠ Posted by uvesh in


How To make sql connection using C# Asp.net

The first of all need to do when interacting with a data base is to create a connection. It Microsoft SQL Server is a relational database management system developed by Microsoft.
Manages all of the low level logic associated with the specific database protocols. In code is instantiate the connection object, open the connection, and then close the connection when you are done. Because of the way that other classes in ADO.NET are built, sometimes you don't even have to do that much work.

Although working with connections is very easy, you need to understand connections in order to make the right decisions when coding your data access routines. Understand that a connection is a valuable resource. 

Following code write down in code behind page (aspx.cs page) For import Class Library of .net

using System.Data.SqlClient;


Following code write down in code behind page (aspx.cs page) For make connection 


SqlConnection myConnection = new SqlConnection("user id=username;" + 
                                       "password=password;server=serverurl;" + 
                                       "Trusted_Connection=yes;" + 
                                       "database=database; " + 

                                       "connection timeout=30");



This is the last part of getting connected and is simply executed by the following (remember to make sure your connection has a connection string first):

SqlConnection.Open()

This code put in Try Catch because this function may be throw error so try catch is usefull to handle error.

try
{
    myConnection.Open();
}
catch(Exception e)
{

    Console.WriteLine(e.ToString());
}



If our post is useful please share and comment on our post for more post and detail Visit :

http://aspdotnethelpmaster.blogspot.in/

Features of c# or advantage of c#


By This Article We Explain Features of C# 

  1. Modern

  2. Object oriented

  3. Type safe

  4. Version able

  5. consistent

  6. compatible

  7. flexible



1.    Modern : It supports, Automatic garbage collection, modern approach to debugging, rich intrinsic model for error handling, decimal data type for financial.

  1. Object :  It supports object-oriented system, namely Encapsulation, Inheritance and Polymorphism.
  1. Type-Safe :
                                                               i.      Type safety promotes robust programs, C# incorporates a number of type-safe measures.
                                                             ii.      All dynamically allocated object and arrays are initialized to zero.
                                                            iii.      Use of any uninitialized variables produces an error message by the compilers
                                                            iv.      Access to array are range checked and warned if it  goes out-of-bounds.
                                                             v.      C# does not permit unsafe casts.
                                                            vi.      C# enforces overflow checking in arithmetic’s operation.
                                                          vii.      Reference parameters that are passed are type-safe.
                                                         viii.      C# supports automatic garbage collection.

  1. Version able :  Making new versions of software modules work with the existing  applications is known as versioning with the help of new and override keywords, With this support, a programmer can guarantee that his new class library will maintain binary compatibility with the existing client application.

  1. Consistent : It supports an unified type system which eliminates the problem of varying ranges of integer types. All types are treated as object and developers can extend the type system simply and easily.

  1. Compatible :   C# enforce the .NET common language requirement and therefore allows interoperation with other .NET language.
C# Advantage





If our post is useful please share and comment on our post for more post and detail Visit :

http://aspdotnethelpmaster.blogspot.in/