Thursday, 8 September 2016

Asp dot net Repeater Control using C sharp


Asp.net Repeater Control using C#. This tutorial helps you to create a repeater control using c# step by step.



    

Step-1:
       First you have to create a repeater control or drag and drop it from the toolbox then add itemtemplete tag which is repeating the data inside the repeater control tag.

Step-2:
      After that you have to add div tag then add table tag for the better alignment as i have added inside the div tag.

Step-3:
     And create table row and inside that row add table head and create similar row and add table data as i have created. In that i have five rows which are student-name, register no, DOB, DOE and department. So i am going to repeat this fields in the repeater so look out this html code as i have created like this. 

 HTML code: 

<asp:Repeater ID="Repeater1" runat="server">
      <ItemTemplate>
          <div class="rptr">
          <table>
          <tr><th colspan="2">Student <%#Eval("S_ID") %>" /></th></tr>
          <tr><td>Student Name</td><td><%#Eval("Student_Name") %></td></tr>
          <tr><td>Register No</td><td><%#Eval("Register_No") %></td></tr>
          <tr><td>Date of Birth</td><td><%#Eval("D_O_B") %></td></tr>
          <tr><td>Date of Examination</td><td><%#Eval("D_O_E") %></td></tr>
          <tr><td>Department</td><td><%#Eval("Department") %></td></tr>
          </table>           
          </div>
      </ItemTemplate>
    </asp:Repeater>

Step-4:
         After that create 'rptr' class in css and add this class in div tag so that it looks pretty nice to your Repeater Table.

 CSS code: 


.rptr table
{
background: #eee;
font: 14px segoe ui;
border-collapse: collapse;
width: 25%;
margin: 5px;
float: left;
}
.rptr table th
{
background: #f90;
color: #fff;
padding: 8px 10px;
text-align: left;
}
.rptr table td
{
padding: 5px 10px;
}

Step-5: 
        Then go to the backend which is in the c# and create sql connection then get the
values from the database and fill all the values in the datatable then filter out those datas in the Repeater as i have create simply look out this code. 

 c# code: 


        SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=Vprs;Integrated Security=True");

        SqlDataAdapter sda = new SqlDataAdapter("select * from Student_Details", con);
        DataTable dt = new DataTable();
        sda.Fill(dt);

        Repeater1.DataSource = dt;
        Repeater1.DataBind();

Tuesday, 7 April 2015

Image retrieve from sql server using asp.net c#

Retrieving image from sql server using asp.net with c#. In this tutorial you will learn how to retrieve image which you have uploaded in database with simple and easy method.



Image Upload in sql server using asp.net with c#



Uploading image in sql server using asp.net with c#. In this turorial you can learn how to upload and save image path in the sql server with simple and easy method.