使用GridView控件内面板的Ajax TabContainer的,一个按钮的TabContainer的外 [英] Ajax tabContainer using GridView inside panel, one button outside of the tabContainer

查看:86
本文介绍了使用GridView控件内面板的Ajax TabContainer的,一个按钮的TabContainer的外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建管理面板使用其中有5 tapPanels阿贾克斯标签的容器,并在每个tapPanel,我已经从标准工具的一个小组。并且每个面板中,我的GridView显示添加的数据。最后,我有阿贾克斯TabContainer的外面的一个Add按钮。我会后设计的,如果它允许。问题是,我不知道编码TabContainer的。我已经创建了10个方法,所以我可以把它当添加按钮的点击。

下面是我的code这是行不通的。

 命名空间Admin_Panel
{
    公共部分类地址:System.Web.UI.Page
    {
        保护无效的Page_Load(对象发件人,EventArgs的)
        {
            会话[页] =添加;
        }

        保护无效btnAddCat_Click(对象发件人,EventArgs的)
        {
            AjaxControlToolkit.TabContainer容器=(AjaxControlToolkit.TabContainer)TabConAddInfo;
            AjaxControlToolkit.TabPanel tcTabPanel =新AjaxControlToolkit.TabPanel();

            如果(tcTabPanel.HeaderText ==泼水节)
            {
                addSplash();
                lblMsgAdd.Text =成功添加;
            }
            否则,如果(tcTabPanel.HeaderText ==主目录)
            {
                addMainCat();
                lblMsgAdd.Text =成功添加;
            }
            否则,如果(tcTabPanel.HeaderText ==子类别)
            {
                addSubCat();
                lblMsgAdd.Text =成功添加;
            }
            否则,如果(tcTabPanel.HeaderText ==业务联系人)
            {
                addBusinessContact();
                lblMsgAdd.Text =成功添加;
            }
            否则,如果(tcTabPanel.HeaderText ==人联络)
            {
                addPersonContact();
                lblMsgAdd.Text =成功添加;
            }
        }

       的Int32文件长度= 0;
       字符串connStr = WebConfigurationManager.ConnectionStrings [连接]的ConnectionString。

        私人无效addSplash()
        {
            HttpPostedFile uploadFile = FileLogo.PostedFile;
            文件长度= uploadFile.ContentLength;

            如果(文件长度== 0)
            {
                字符串的文件路径=使用Server.Mappath(@\风格\ IMG \无照片icon.jpg);
                字符串文件名= Path.GetFileName(文件路径);

                的FileStream FS =新的FileStream(文件路径,FileMode.Open,FileAccess.Read);
                文件长度=(Int32)已fs.Length;
                字节[] fileByteArr =新的字节[文件长度]
                fs.Read(fileByteArr,0,文件长度);

                SqlConnection的康恩=新的SqlConnection(connStr);
                的SqlCommand CMD =新的SqlCommand(插入SPLASH(将VersionNumber,SplashLabel,为LoginID)值(@将VersionNumber,@ SplashLabel,@为LoginID),康涅狄格州);

                cmd.Parameters.AddWithValue(@将VersionNumber,txtVnum.Value);
                cmd.Parameters.AddWithValue(@ SplashLabel,txtSpLabel.Value);
                cmd.Parameters.AddWithValue(@为LoginID,txtYourID.Value);
                cmd.Parameters.AddWithValue(@的ImageData,fileByteArr);
                cmd.Parameters.AddWithValue(@ ImageContentType,图像/ JPG);
                cmd.Parameters.AddWithValue(@ IMAGESIZE,文件长度);

                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
                conn.Dispose();
                cmd.Dispose();

            }
            其他
            {
                字节[] fileByteArray =新的字节[文件长度]
                流streamObject = uploadFile.InputStream;
                streamObject.Read(fileByteArray,0,文件长度);

                SqlConnection的康恩=新的SqlConnection(connStr);
                的SqlCommand CMD =新的SqlCommand(插入SPLASH(将VersionNumber,SplashLabel,为LoginID)值(@将VersionNumber,@ SplashLabel,@为LoginID),康涅狄格州);

                cmd.Parameters.AddWithValue(@将VersionNumber,txtVnum.Value);
                cmd.Parameters.AddWithValue(@ SplashLabel,txtSpLabel.Value);
                cmd.Parameters.AddWithValue(@为LoginID,txtYourID.Value);
                cmd.Parameters.AddWithValue(@的ImageData,fileByteArray);
                cmd.Parameters.AddWithValue(@ ImageContentType,图像/ JPG);
                cmd.Parameters.AddWithValue(@ IMAGESIZE,文件长度);


                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
                conn.Dispose();
                cmd.Dispose();
            }
        }

        私人无效showSplash()
        {
            SqlConnection的康恩=新的SqlConnection(connStr);
            的SqlCommand CMD =新的SqlCommand(选择SPLASH *,康涅狄格州);

            conn.Open();
            SqlDataReader的RDR = cmd.ExecuteReader();
            System.Data.DataTable DT =新System.Data.DataTable();
            dt.Load(RDR);
            GridViewAddSplash.DataSource = DT;
            GridViewAddSplash.DataBind();
            conn.Close();
            conn.Dispose();
            cmd.Dispose();
        }

        私人无效addMainCat()
        {
        }
        私人无效showMainCat()
        {
        }
        私人无效addSubCat()
        {
        }
        私人无效showSubCat()
        {
        }
        私人无效addBusinessContact()
        {
        }
        私人无效showBusinessContact()
        {

        }

        私人无效addPersonContact()
        {
        }
        私人无效showPersonContact()
        {
        }
    }
}
 

解决方案

请使用以下code:

  AjaxControlToolkit.TabContainer容器=(AjaxControlToolkit.TabContainer)TabConAddInfo;
        INT指数= container.ActiveTabIndex;

        如果(指数== 0)
        {
            addSplash();
            lblMsgAdd.Text =成功添加;
        }
        否则,如果(指数== 1)
        {
            addMainCat();
            lblMsgAdd.Text =成功添加;
        }
        否则,如果(指数== 2)
        {
            addSubCat();
            lblMsgAdd.Text =成功添加;
        }
        否则,如果(指数== 3)
        {
            addBusinessContact();
            lblMsgAdd.Text =成功添加;
        }
        否则,如果(指数== 4)
        {
            addPersonContact();
            lblMsgAdd.Text =成功添加;
        }
 

I'm creating Admin Panel using Ajax tab container which has 5 tapPanels and in that each tapPanel, I have one Panel from standard tool. And in that each Panel, I have GridView to show added data. And finally, I have one Add button outside of the Ajax tabContainer. I'll post the design if it allows. The problem is, I don't know the coding for tabContainer. I've created 10 methods so I can call it when Add button clicks.

Here is my code which is not working.

namespace Admin_Panel
{
    public partial class add : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["Page"] = "ADD";           
        }

        protected void btnAddCat_Click(object sender, EventArgs e)
        {
            AjaxControlToolkit.TabContainer container = (AjaxControlToolkit.TabContainer)TabConAddInfo;
            AjaxControlToolkit.TabPanel tcTabPanel = new AjaxControlToolkit.TabPanel();

            if (tcTabPanel.HeaderText == "Splash")
            {
                addSplash();
                lblMsgAdd.Text = "Added successfully";
            }
            else if (tcTabPanel.HeaderText == "Main Category")
            {
                addMainCat();
                lblMsgAdd.Text = "Added successfully";
            }
            else if (tcTabPanel.HeaderText == "Sub Category")
            {
                addSubCat();
                lblMsgAdd.Text = "Added successfully";
            }
            else if (tcTabPanel.HeaderText == "Business Contact")
            {
                addBusinessContact();
                lblMsgAdd.Text = "Added successfully";
            }
            else if (tcTabPanel.HeaderText == "Person Contact")
            {
                addPersonContact();
                lblMsgAdd.Text = "Added successfully";
            }            
        }

       Int32 fileLength = 0;
       string connStr = WebConfigurationManager.ConnectionStrings["connection"].ConnectionString;

        private void addSplash()
        {
            HttpPostedFile uploadFile = FileLogo.PostedFile;
            fileLength = uploadFile.ContentLength;

            if (fileLength == 0)
            {
                string filePath = Server.MapPath(@"\style\img\no-photo-icon.jpg");
                string fileName = Path.GetFileName(filePath);

                FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
                fileLength = (Int32)fs.Length;
                Byte[] fileByteArr = new Byte[fileLength];
                fs.Read(fileByteArr, 0, fileLength);

                SqlConnection conn = new SqlConnection(connStr);
                SqlCommand cmd = new SqlCommand("insert into SPLASH (VersionNumber, SplashLabel,LoginID) values (@VersionNumber,@SplashLabel,@LoginID)", conn);

                cmd.Parameters.AddWithValue("@VersionNumber", txtVnum.Value);
                cmd.Parameters.AddWithValue("@SplashLabel", txtSpLabel.Value);
                cmd.Parameters.AddWithValue("@LoginID", txtYourID.Value);
                cmd.Parameters.AddWithValue("@ImageData", fileByteArr);
                cmd.Parameters.AddWithValue("@ImageContentType", "image/jpg");
                cmd.Parameters.AddWithValue("@ImageSize", fileLength);

                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
                conn.Dispose();
                cmd.Dispose();

            }
            else
            {
                Byte[] fileByteArray = new Byte[fileLength];
                Stream streamObject = uploadFile.InputStream;
                streamObject.Read(fileByteArray, 0, fileLength);

                SqlConnection conn = new SqlConnection(connStr);
                SqlCommand cmd = new SqlCommand("insert into SPLASH (VersionNumber, SplashLabel,LoginID) values (@VersionNumber,@SplashLabel,@LoginID)", conn);

                cmd.Parameters.AddWithValue("@VersionNumber", txtVnum.Value);
                cmd.Parameters.AddWithValue("@SplashLabel", txtSpLabel.Value);
                cmd.Parameters.AddWithValue("@LoginID", txtYourID.Value);
                cmd.Parameters.AddWithValue("@ImageData", fileByteArray);
                cmd.Parameters.AddWithValue("@ImageContentType", "image/jpg");
                cmd.Parameters.AddWithValue("@ImageSize", fileLength);


                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
                conn.Dispose();
                cmd.Dispose();
            }
        }

        private void showSplash()
        {
            SqlConnection conn = new SqlConnection(connStr);
            SqlCommand cmd = new SqlCommand("select * from SPLASH", conn);

            conn.Open();
            SqlDataReader rdr = cmd.ExecuteReader();
            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Load(rdr);
            GridViewAddSplash.DataSource = dt;
            GridViewAddSplash.DataBind();
            conn.Close();
            conn.Dispose();
            cmd.Dispose();
        }

        private void addMainCat()
        {
        }        
        private void showMainCat()
        {           
        }
        private void addSubCat()
        {            
        }
        private void showSubCat()
        {          
        } 
        private void addBusinessContact()       
        {                                  
        } 
        private void showBusinessContact()
        {

        }

        private void addPersonContact()
        {                    
        } 
        private void showPersonContact()
        {           
        }        
    }
}

解决方案

Please use the following code:

        AjaxControlToolkit.TabContainer container = (AjaxControlToolkit.TabContainer)TabConAddInfo;
        int index = container.ActiveTabIndex;

        if (index == 0)
        {
            addSplash();
            lblMsgAdd.Text = "Added successfully";
        }
        else if (index == 1)
        {
            addMainCat();
            lblMsgAdd.Text = "Added successfully";
        }
        else if (index == 2)
        {
            addSubCat();
            lblMsgAdd.Text = "Added successfully";
        }
        else if (index == 3)
        {
            addBusinessContact();
            lblMsgAdd.Text = "Added successfully";
        }
        else if (index == 4)
        {
            addPersonContact();
            lblMsgAdd.Text = "Added successfully";
        }     

这篇关于使用GridView控件内面板的Ajax TabContainer的,一个按钮的TabContainer的外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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