Ajax tabContainer的C#代码在面板内部使用girdview,面板外部有一个按钮 [英] C# code for Ajax tabContainer using girdview inside panel, one button outside of panel

查看:49
本文介绍了Ajax tabContainer的C#代码在面板内部使用girdview,面板外部有一个按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是这个网站的新手,也是编程新手。



我在这里遇到了C#编码。我用Google搜索了很多次,但决定在这里发一个问题。

我正在使用Ajax标签容器创建管理面板,该容器有5个tapPanel,每个tapPanel,我有一个标准工具面板。在每个Panel中,我都有GridView来显示添加的数据。最后,我在Ajax tabContainer之外有一个Add按钮。如果允许,我会发布设计。问题是,我不知道tabContainer的编码。我创建了10个方法,所以我可以在添加按钮单击时调用它。



这是我的代码无效。在此先感谢!!!





  namespace  Admin_Panel 
{
public partial 添加:System.Web.UI.Page
{
protected void Page_Load( object sender,EventArgs e)
{
会话[ Page] = ADD;
}


受保护 void btnAddCat_Click(< span class =code-keyword> object sender,EventArgs e)
{
AjaxControlToolkit.TabContainer container =(AjaxControlToolkit.TabContainer)TabConAddInfo;
AjaxControlToolkit.TabPanel tcTabPanel = new AjaxControlToolkit.TabPanel();

if (tcTabPanel.HeaderText == Splash
{
addSplash();
lblMsgAdd.Text = 已成功添加;
}
else if (tcTabPanel.HeaderText == 主要类别
{
addMainCat();
lblMsgAdd.Text = 已成功添加;
}
else if (tcTabPanel.HeaderText == 子类别
{
addSubCat();
lblMsgAdd.Text = 已成功添加;
}
else if (tcTabPanel.HeaderText == 业务联系人
{
addBusinessContact();
lblMsgAdd.Text = 已成功添加;
}
else if (tcTabPanel.HeaderText == 人员联系人
{
addPersonContact();
lblMsgAdd.Text = 已成功添加;
}

}

Int32 fileLength = 0 ;
string connStr = WebConfigurationManager.ConnectionStrings [ 连接]的ConnectionString。

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

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

FileStream fs = new FileStream(filePath,FileMode.Open,FileAccess.Read);
fileLength =( Int32 )fs.Length;
字节 [] fileByteArr = new 字节< /跨度> [文件长度];
fs.Read(fileByteArr, 0 ,fileLength);

SqlConnection conn = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand( insert到SPLASH(VersionNumber,SplashLabel,LoginID)值(@ 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();

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

SqlConnection conn = new SqlConnection(connStr);
< code> SqlCommand cmd = new SqlCommand( 插入SPLASH(VersionNumber,SplashLabel,LoginID)值(@ 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();
}
}

私人 void showSplash( )
{
SqlConnection conn = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand( select *来自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();
}

私有 void addMainCat()
{
}


private void showMainCat( )
{

}

private void addSubCat()
{

}

private void showSubCat()
{

}

private void addBusinessContact()

{

}

private void showBusinessContact()
{

}

private void addPersonContact()
{

}

private void showPersonContact()
{

}

}
}

解决方案

Hi, I'm new to this site and new to programming.

I'm stuck in C# coding here. I've Googled so many times but decided to post a question here.
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. Thanks in advance!!!


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);
                <code>SqlCommand cmd = new SqlCommand("insert into SPLASH (VersionNumber, SplashLabel,LoginID) values (@VersionNumber,@SplashLabel,@LoginID)", conn);</code>

                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()
        {
           
        }
        
    }
}

解决方案

这篇关于Ajax tabContainer的C#代码在面板内部使用girdview,面板外部有一个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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