0

基本上我想将一些数据插入到现有的 slickgrid 数据视图中

dataView.addItem();

所以,我需要 div #myGrid中我的 slickgrid 数据视图的数据视图对象

4

2 回答 2

0

尝试这个:

要查找数据网格,您必须使用 $.find()

var MyGrid=$.find(<%=myGrid.ClientID%>)
于 2013-10-04T09:46:39.470 回答
0
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        string connetionString = null;
        SqlConnection connection ;
        SqlCommand command ;
        SqlDataAdapter adapter = new SqlDataAdapter();
        DataSet ds = new DataSet();
        DataView dv ;
        string sql = null;
        connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password";
        sql = "Select * from product";
        connection = new SqlConnection(connetionString);
        try
        {
            connection.Open();
            command = new SqlCommand(sql, connection);
            adapter.SelectCommand = command;
            adapter.Fill(ds, "Add New");
            adapter.Dispose();
            command.Dispose();
            connection.Close();

            dv = new DataView(ds.Tables[0]);
            DataRowView newRow = dv.AddNew();
            newRow["Product_ID"] = 7;
            newRow["Product_Name"] = "Product 7";
            newRow["Product_Price"] = 111;
            newRow.EndEdit();
            dv.Sort = "product_id";


            dataGridView1.DataSource = dv;
        }
        catch (Exception ex)
        {
            MessageBox.Show (ex.ToString());
        }
    }
}
于 2013-10-04T09:39:22.047 回答