Thursday, December 22, 2011

Fetch the gridview data and display next page textboxes throw Query string using ASP.NET


 protected void grdMyIdea_RowCommand(object sender, GridViewCommandEventArgs e)
        { 
            try
            {
              
                if (e.CommandName == "Edit")
                {
                    Response.Redirect("sampleidea.aspx?Ideaid=" +e.CommandArgument );
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

ANOTHER PAGE: Ideaid is primarykey is also used in this table..fetch by another table Title and Description how? 

 protected void Page_Load(object sender, EventArgs e)
 {
           int Ideaid = 0;
           Ideaid = Convert.ToInt32(Request.QueryString["Ideaid"].ToString());
          
            if (!IsPostBack)
            {
                Getdata();
            }

public void Getdata()
        {
            SqlConnection con = new SqlConnection(connection);
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter("select Title,Description from Idea where Ideaid='" + Request.QueryString["Ideaid"].ToString() + "'", con);
            con.Close();
            DataSet ds = new DataSet();
            da.Fill(ds);
            TextBox1.Text = ds.Tables[0].Rows[0]["Title"].ToString();
            TextBox2.Text = ds.Tables[0].Rows[0]["Description"].ToString();
           
           
        }
 

No comments:

Post a Comment