Friday, 2 May 2014

Write code in .aspx page using datarow

No comments
.aspx

 <table>
        <tr>
            <td>
                <%
                  
                    about();
                    foreach (System.Data.DataRow dr in dt.Rows)
                    {
                        Response.Write(dr["Content"]);
                    }
                  
                     %>
            </td>
        </tr>
    </table>.cs


public void abt_us()
    {
        dt = bl.view_about_us();
    }
public DataTable view_about_us()
    {
        con.Open();
        cmd = new SqlCommand("select * from xyzus", con);       
        DataTable dt = new DataTable();
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        da.Fill(dt);
        con.Close();
        return dt;
    }