Tuesday, April 30, 2013

How to bind Gridview using Sqldataadapter, Datatable and Query in Asp.net(C#, VB)?


Introduction: In this post I have try to explain how to bind Gridview in Asp.net.

Description:
I have create a table name STUDENT_DETAIL and insert data into table.
STUDENT_ID
int
STUDENT_NAME
varchar(50)
STUDENT_ADDRESS
varchar(50)
STUDENT_CLASS
varchar(50)

STUDENT_ID is primary key.

Now open the Visual Studio>Go to File>New>Website. Add the Connectionstring in web.config file of website.
<configuration>
       <connectionStrings>
    <add name="connection" connectionString="Data Source=SYS-1F78031ED0A;Initial Catalog=TestBlog;Integrated Security=True"/>
       </connectionStrings>
       <system.web>
        <compilation debug="true" targetFramework="4.0" />
    </system.web>
</configuration>


After that add new web form to website, drag and drop the Gridview data control from

How to send E-mail in Asp.net using web.config?


Introduction:In this post I go to tell you to send E-mail using web.config. Sometime we create a web application and there is lot of form to send E-email to users. If in future E-mail address of Administration will change then we have to change the E-mail address of Administration in every web form.  If we want it would not happen in future so we mention the E-mail address detail in web.config file of application.
Description:
Now see how we can do it simply. Add the below mention information in web.config file.
<appSettings>
    <add key="Email" value="your E-mail address"/>
  </appSettings>
  <system.net>
    <mailSettings>
      <smtp deliveryMethod="Network">
        <network enableSsl="true" port="587" host="smtp.gmail.com" userName="E-mail addrerss" password="Password"/>
      </smtp>
    </mailSettings>
</system.net>
Now add a web form to application.
  <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
    <table>
    <tr><td>Email Address</td><td>
        <asp:TextBox ID="txtemail" runat="server"></asp:TextBox></td></tr>
        <tr><td>Subject</td><td>
            <asp:TextBox ID="txtsubject" runat="server"></asp:TextBox></td></tr>
            <tr><td>Comment</td><td>
                <cc1:Editor ID="Editor1" runat="server" />
                &nbsp;</td></tr>
                <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
                <tr><td></td><td><asp:Button ID="dtnsend" runat="server" Text="Send" onclick="dtnsend_Click" />
                    </td></tr>
    </table>
   

Monday, April 29, 2013

How to insert data into database using LINQ?



Introduction: In this post I will explain how to insert data into database using LINQ.

Description:

Create a table name LINQ_TABLE.



Now go to Visual studio>File>New website>Asp.net empty web site. Now go to Solution Explorer, right click on website>Add new item>Linq to Sql classes.


Now you see App_code folder will added to application and a dataclasses added with extension .dbml in App_code folder.

How to bind repeater in Asp.net?


Introduction: In this post I will show you how to use Repeater control in Asp.net. Commonly we used repeater to show data.
Description:
 I have created a table:


Now open the Visual Studio>Go to File>New>Website. Add the Connectionstring in web.config file of website.
<configuration>
       <connectionStrings>
    <add name="connection" connectionString="Data Source=SYS-1F78031ED0A;Initial Catalog=TestBlog;Integrated Security=True"/>
       </connectionStrings>
       <system.web>
        <compilation debug="true" targetFramework="4.0" />
    </system.web>
</configuration>

Friday, April 26, 2013

How to Bind, Edit, Update and Delete in Repeater control in Asp.net?



Introduction: Most of developer thinks Repeater is only used to display the data. Here I try to explain how we can edit, update and delete the data using repeater control via Itemcommand.

Description:

I have create table name Repeater.

Now open the Visual Studio>Go to File>New>Website. Add the Connectionstring in web.config file of website.
<configuration>
       <connectionStrings>
    <add name="connection" connectionString="Data Source=SYS-1F78031ED0A;Initial Catalog=TestBlog;Integrated Security=True"/>
       </connectionStrings>
       <system.web>
        <compilation debug="true" targetFramework="4.0" />
    </system.web>
</configuration>