User Profile & Activity

Frank Bruce Member
Page
of 15
Posted: September 7, 2010 2:56 AM

NO,DblClick one cell of WebGrid2 then  did not focus back into WebGrid1, focus into WebGrid2 again.

(When I  DblClick one cell of WebGrid2 ,one cell of webgrid1 Get Focus  but at  once the cell of webgrid1 lost  Focus  and the cell of WebGrid2 Get Focus again.I think the reason is:DblClick  event cause cell into EditState,can not lostfocus from EditState.what is your suggest?? )

But I want to DblClick one cell of WebGrid2,the cell lost Focus and  one of webgrid1 Get Focus !

Hope you can help me!thank you!

Posted: September 6, 2010 5:44 AM

thank you Yudi :

You are really a smart Man!!

Posted: September 3, 2010 5:30 AM

I have rewrite OnCellDblClick!
WebGrid2:<ClientSideEvents OnCellDblClick="WebGrid2_Dbclick"  />

I want to do:

when i DblClick one cell of WebGrid2,the cell lost Focus and  one of webgrid1 Get Focus

BUT the problem is that:

when i DblClick one cell of WebGrid2(How to Cancel dblClick  Cell into EditState,because I still want to Use Edit!!!!),one cell of webgrid1 Get Focus  but at  once the cell of webgrid1

lost  Focus  and the cell of WebGrid2 Get Focus  Again

WebGrid2_Dbclick Code:


function WebGrid2_Dbclick() {
    var grid1 = ISGetObject("WebGrid1");
    var grid2 = ISGetObject("WebGrid2");
    var totalRowCount = grid1.TotalRows;      
    var paRow = grid2.GetSelectedObject().GetRowObject();
      var childRow = grid1.RootTable.NewRow();         
      var pacell = paRow.GetCells();
     var chilcell = childRow.GetCells();        
        var s1 = pacell.GetNamedItem("商品编号").Text;
        var s2 = pacell.GetNamedItem("商品名称").Text;
        var s3 = pacell.GetNamedItem("商品规格").Text;
        var s4 = pacell.GetNamedItem("包装单位").Text;
        var s5 = pacell.GetNamedItem("数量").Text;
        chilcell.GetNamedItem("vouid").SetText(totalRowCount + 1, true);
        chilcell.GetNamedItem("商品编号").SetText(s1, true);
        chilcell.GetNamedItem("商品名称").SetText(s2, true);
        chilcell.GetNamedItem("商品规格").SetText(s3, true);
        chilcell.GetNamedItem("包装单位").SetText(s4, true);
        chilcell.GetNamedItem("数量").SetText(s5, true);
        grid1.XmlHttp.Asynchronous = false;
        childRow.Update();
        grid1.SetFocus();
        grid1.RootTable.GetRow(totalRowCount).Select();
        grid1.RootTable.GetRow(totalRowCount).GetCells()[1].ActivateEdit();
} 
Posted: September 2, 2010 10:31 PM

Hey, thank you Handy~you are so kind to me!!!!

Posted: September 2, 2010 10:26 PM

Hi Yudi,

I have Creat a Webgrid by your way~

but when I click  "Refresh" of the webgrid , the  page also refresh!It seems  that it is very Bad!

How to:  click  "Refresh" of the webgrid ,but  the  page doen not refresh?

Waiting for you on line!!!!!

My c# Code(You may change your language to Chinese):

        #region dynamicCreateWebgrid
        protected void Button11_Click1(object sender, EventArgs e)
        {
            dynamicGridInit();
        }    
        public void dynamicGridInit()
        {
            WebGrid grid = new WebGrid();
            grid.ID = "WebGrid5";
            grid.Width = System.Web.UI.WebControls.Unit.Pixel(800);
            grid.Height = System.Web.UI.WebControls.Unit.Pixel(100);
            grid.UseDefaultStyle = true;

            grid.InitializeDataSource += new ISNet.WebUI.WebGrid.DataSourceEventHandler(grid_InitializeDataSource);
            grid.PrepareDataBinding += new ISNet.WebUI.WebGrid.DataSourceEventHandler(grid_PrepareDataBinding);
            grid.InitializeLayout += new ISNet.WebUI.WebGrid.LayoutEventHandler(grid_InitializeLayout);
            form1.Controls.Add(grid);        
        }
        private void grid_PrepareDataBinding(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)
        {
            //if (!IsPostBack)
            //{
             WebGrid grid = (WebGrid)sender;               
              grid.RetrieveStructure();
            //}
         
        }
        protected void grid_InitializeLayout(object sender, ISNet.WebUI.WebGrid.LayoutEventArgs e)
        {
            WebGrid grid = (WebGrid)sender;   
            grid.LayoutSettings.AllowContextMenu = true;
            grid.LayoutSettings.AllowExport = Export.Yes;
            grid.LayoutSettings.AlternatingColors = false;
            grid.LayoutSettings.AllowSelectColumns = SelectColumns.Yes;
            grid.LayoutSettings.AllowEdit = Edit.Yes;           
            grid.LayoutSettings.StatusBarStyle.BackColor = System.Drawing.Color.Chocolate;
        }
        protected void grid_InitializeDataSource(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)
        {
            e.DataSource = mytb();
        }
        public DataSet mytb()
        {

            DataSet ds = new DataSet("tb_Employee");
            ds.ExtendedProperties["TimerStamp"] = DateTime.Now;
            ds.ExtendedProperties["Company"] = "www.sina.com";

            DataColumn EmployeeIDColumn = new DataColumn("EmployeeID", typeof(int));
            EmployeeIDColumn.Caption = "员工编号";
            EmployeeIDColumn.ReadOnly = true;
            EmployeeIDColumn.AllowDBNull = false;
            EmployeeIDColumn.Unique = true;
            EmployeeIDColumn.AutoIncrement = true;
            EmployeeIDColumn.AutoIncrementSeed = 0;
            EmployeeIDColumn.AutoIncrementStep = 1;

            DataColumn EName = new DataColumn("EName", typeof(string));
            DataColumn ESex = new DataColumn("ESex", typeof(string));
            DataColumn EAge = new DataColumn("EAge", typeof(int));
            DataColumn EPlace = new DataColumn("EPlace", typeof(string));
            DataColumn EMoney = new DataColumn("EMoney", typeof(int));
            DataTable dt = new DataTable("tb_Employee");
            dt.Columns.AddRange(new DataColumn[] { EmployeeIDColumn, EName, ESex, EAge, EPlace, EMoney });

            DataRow dr = dt.NewRow();
            dr["EName"] = "huangjshhhh";
            dr["ESex"] = "男";
            dr["EAge"] = 20;
            dr["EPlace"] = "上海";
            dr["EMoney"] = 10000;
            dt.Rows.Add(dr);

            dr = dt.NewRow();
            dr["EName"] = "chengshuang";
            dr["ESex"] = "女";
            dr["EAge"] = 20;
            dr["EPlace"] = "北京";
            dr["EMoney"] = 10000;
            dt.Rows.Add(dr);

            dt.PrimaryKey = new DataColumn[] { dt.Columns[0] };
            ds.Tables.Add(dt);
            return ds;
        }

       #endregion
Posted: September 1, 2010 9:22 PM

thank you Handy Surya:

I think I have solved the simple problem by only severside

display the last page:

jscode:

function MoveLastPage()
{
    var grid = ISGetObject("WebGrid1");
    grid.GotoLastPage();
 } 

C#code:
  protected void Button1_Click(object sender, EventArgs e)
    {             
        ScriptManager.RegisterStartupScript(this, this.GetType(), "", "MoveLastPage();", true);     
    }

 

Posted: September 1, 2010 2:53 AM


thank you Yudi !

Posted: August 31, 2010 3:19 AM

thank you  Handy Surya;

the answer is perfect!

 

Posted: August 30, 2010 9:06 PM
Like this:
:using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using H.Database;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ISNet.WebUI.WebGrid;
using ISNet.WebUI.WebCombo;

namespace WebApplication1
{
    public partial class Demo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindList();
            }
        }
        protected void BindList()
        {
            using (StoreDA da = new StoreDA())
            {
                var aa = da.Query();

                this.WebGrid1.DataSource = da.Query1(TextBox1.Text);
                WebGrid1.RetrieveStructure();
                WebGrid1.DataBind();   
             
                WebGrid1.RootTable.DataKeyField = "序列号";
                WebGrid1.RootTable.Columns.GetNamedItem("序列号").IsRowChecker = true;
                         }
        }

          protected void WebGrid1_InitializeDataSource(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)
        {
            //  BindList();
            using (StoreDA da = new StoreDA())
            {
                var aa = da.Query1("");//this is a  query SQl,get a datatable
                e.DataSource = aa;
                WebGrid1.RetrieveStructure();
                WebGrid1.RootTable.DataKeyField = "序列号";
                WebGrid1.DataBind();
                WebGrid1.RootTable.Columns.GetNamedItem("序列号").IsRowChecker = true;
            }
        }

        protected void WebGrid1_PrepareDataBinding(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            using (StoreDA da = new StoreDA())
            {
                var aa = da.Query1(TextBox1.Text);
                WebGrid1.DataSource = aa;
                WebGrid1.RetrieveStructure();
                WebGrid1.RootTable.DataKeyField = "序列号";
                WebGrid1.DataBind();
                WebGrid1.RootTable.Columns.GetNamedItem("序列号").IsRowChecker = true;
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            using (StoreDA da = new StoreDA())
            {
                var aa = da.Query2(TextBox2.Text);
                WebGrid1.DataSource = aa;
                WebGrid1.RetrieveStructure();
                WebGrid1.RootTable.DataKeyField = "序列号";
                WebGrid1.DataBind();
                WebGrid1.RootTable.Columns.GetNamedItem("序列号").IsRowChecker = true;
            }
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            using (StoreDA da = new StoreDA())
            {
                var aa = da.Query3(TextBox3.Text);
                WebGrid1.DataSource = aa;
                WebGrid1.RetrieveStructure();
                WebGrid1.RootTable.DataKeyField = "序列号";
                WebGrid1.DataBind();
                WebGrid1.RootTable.Columns.GetNamedItem("序列号").IsRowChecker = true;
            }
        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            using (StoreDA da = new StoreDA())
            {
                var aa = da.Query4(TextBox4.Text);
                WebGrid1.DataSource = aa;
                WebGrid1.RetrieveStructure();
                WebGrid1.RootTable.DataKeyField = "序列号";
                WebGrid1.DataBind();
                WebGrid1.RootTable.Columns.GetNamedItem("序列号").IsRowChecker = true;
            }
        }
    
when I input some informations and click a button,get a new dataset,I want bind the dataset to the same webgrid!How can I do ?Please help me!thank you!
All times are GMT -5. The time now is 8:33 PM.
Previous Next