如何将GridView行值发送到其他页面 [英] how to send gridview row values to other page

查看:129
本文介绍了如何将GridView行值发送到其他页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用c#

推荐答案

Check这个:将值从datagrid传递到另一个页面 [ ^ ]
希望对您有所帮助.
Check this one: Passing values from datagrid to another page[^]
Hope it helps..


HI

您可以在此
中使用以下方法
1)previouspage.findcontrol("testdatatable")作为数据表;

您将获得所有值

2)您也可以使用会话变量session ["datatable"]

希望对您有帮助

祝你好运

谢谢
HI

you can use the following mathod for this

1)previouspage.findcontrol("testdatatable") as datatable;

and you will get all the values

2)You can also use the session variable session["datatable"]

Hope it will help you

best luck

Thanks


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using BusinessLogicLayer;

public partial class Admin_EditItem : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
   
        {

            if (!IsPostBack)
            {

                    int PID = Convert.ToInt32(Request.QueryString["ID"]);
                    Session["Pid"] = PID;
               
                fillProductInfo();

            }
                   
    }


    protected void btn_add_Click(object sender, EventArgs e)
    {


        productBLL objproductBLL = new productBLL();

        objproductBLL.Product_Id = 0;
        objproductBLL.ProductName = txt_Pname.Text;


        objproductBLL.Category_Id = Convert.ToInt32(ddl_catg.SelectedValue);
        objproductBLL.Sales_Price = Convert.ToSingle(txt_price.Text.Trim());
        objproductBLL.Description = txt_desc.Text;

        if (FileUpload1.HasFile)
        {
            if (CheckExtension(FileUpload1.FileName))
            {
                if (FileUpload1.PostedFile.ContentLength < 1000000000)
                {
                    string Path = Server.MapPath("~/images/");
                    Path = Path + "//" + FileUpload1.FileName;
                    FileUpload1.SaveAs(Path);

                }
                else
                {

                }
            }
        }

        else
        {



        }


        objproductBLL.ProductImage = "~/images/" + FileUpload1.FileName;



        if (objproductBLL.insertupdateproduct() > 0)
        {

            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "PremierStore", "alert('Update  Successful')", true);
        }
        {
            Label1.Text = "Data Has Been entered Successfully!!!!!!";

        }
    }


    private bool CheckExtension(string fileName)
    {
        string extension = Path.GetExtension(fileName);
        switch (extension.ToLower())
        {
            case ".jpg": return true;
            case ".jpeg": return true;
            case ".png": return true;
            case ".gif": return true;
            default: return false;
        }
    }



    private void fillProductInfo()
    {
        productBLL objProductBLL = new productBLL();
        objProductBLL.Product_Id = Convert.ToInt32(Session["Pid"].ToString());
        DataSet ds = new DataSet();
        ds = objProductBLL.SelectProduct();
        if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
        {
            txt_Pname.Text = ds.Tables[0].Rows[0]["productName"].ToString();
            txt_desc.Text = ds.Tables[0].Rows[0]["description"].ToString();
            txt_price.Text = ds.Tables[0].Rows[0]["sales_Price"].ToString();
            Image1.ImageUrl = ds.Tables[0].Rows[0]["productImage"].ToString();
            ddl_catg.SelectedIndex = ddl_catg.Items.IndexOf(ddl_catg.Items.FindByValue(ds.Tables[0].Rows[0]["category_Id"].ToString()));
        }
    }
  protected void clear()
    {
        txt_Pname.Text = "";
        txt_price.Text = "";

        txt_desc.Text = "";


          }

    }


这篇关于如何将GridView行值发送到其他页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆