using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration;
public partial class _Default : System.Web.UI.Page
{
Class1 c = new Class1();
DataSet ds = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
try
{
string sid = Request.QueryString[""].ToString();
string type = Request.QueryString[""].ToString();
SqlConnection cn = new SqlConnection(c.connectionString);
SqlCommand cmd = new SqlCommand("dbo.usp_get_blog_info", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@sid", sid);
cmd.Parameters.AddWithValue("@type", type);
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
da.Fill(ds);
}
catch
{
SqlConnection cn = new SqlConnection(c.connectionString);
SqlCommand cmd = new SqlCommand("dbo.usp_get_blog_info", cn);
cmd.CommandType = CommandType.StoredProcedure;
//cmd.Parameters.Add(new SqlParameter("@sid","10000"));
// cmd.Parameters.Add(new SqlParameter("type", "NULL"));
cmd.Parameters.AddWithValue("@sid", "100000");
cmd.Parameters.AddWithValue("@type", "NULL");
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
FormView1.DataSource = ds;
FormView1.DataBind();
Label l=(Label)FormView1.FindControl("Header");
l.Text =ds.Tables[0].Rows[0]["header"].ToString();
TextBox l1=(TextBox)FormView1.FindControl("Label1");
l1.Text =ds.Tables[0].Rows[0]["matter"].ToString();
}
}
protected void FormView1_PageIndexChanging(object sender, FormViewPageEventArgs e)
{
FormView1.PageIndex = e.NewPageIndex;
int i = e.NewPageIndex;
SqlConnection cn = new SqlConnection(c.connectionString);
SqlCommand cmd = new SqlCommand("dbo.usp_get_blog_info", cn);
cmd.CommandType = CommandType.StoredProcedure;
//cmd.Parameters.Add(new SqlParameter("@sid","10000"));
// cmd.Parameters.Add(new SqlParameter("type", "NULL"));
cmd.Parameters.AddWithValue("@sid", "100000");
cmd.Parameters.AddWithValue("@type", "NULL");
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds1 = new DataSet();
da.Fill(ds1);
FormView1.DataSource = ds;
FormView1.DataBind();
//this new lable l initialize the header label in formview;
Label l = (Label)FormView1.FindControl("Header");
l.Text = ds1.Tables[0].Rows[i]["header"].ToString();
TextBox l1 = (TextBox)FormView1.FindControl("Label1");
l1.Text = ds1.Tables[0].Rows[i]["matter"].ToString();
//FormView1.DataBind();
}
protected void Label1_TextChanged(object sender, EventArgs e)
{
}
}