如何从父网格行ID生成ID,如1.1,1.2.in嵌套网格视图 [英] How to generate ID like 1.1, 1.2.in nested grid view from parent grid row ID

查看:124
本文介绍了如何从父网格行ID生成ID,如1.1,1.2.in嵌套网格视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从网格视图行添加按钮生成嵌套网格视图。如果我单击添加按钮,则必须根据父网格ID生成嵌套网格视图。



例如,父网格id = 1表示单击添加嵌套网格行必须使用自动增量ID生成,而每次单击添加按钮(如1.1,1.2)如果父网格中的第二行表示2.1,2.2这样必须创建在嵌套网格行id中



我尝试过:



而点击添加网格视图行:

使用两个表,同时连接第一行1.1,1.2。如果我在第二行添加它显示2.3如何解决。使用数据表很容易意味着怎么做?

  protected   void  OnSelectedIndexChanged( object  sender,EventArgs e)
{

string Sid = GridState.SelectedRow.Cells [ 1 ]。文字;
SqlConnection con = new SqlConnection(conString);
{
使用(SqlCommand cmd = new SqlCommand( INSERT INTO City VALUES(' + TextBox3.Text + ',' + TextBox4.Text + ' ,' + TextBox5.Text + ', + Sid + ,con))
{

con.Open();
cmd.ExecuteNonQuery();
con.Close();

string sQuery1 = SELECT CAST(S_id AS VARCHAR(20))+'。'+ CAST(City_id AS VARCHAR(20)),City_code,来自City的City_name,其中S_id = + Sid;
string value = getData1(sQuery1).ToString();
// string sQuery =SELECT CAST(S_id AS VARCHAR(20))+'。'+ CAST (City_id AS VARCHAR(20)),City_code,City_name from City;
/// / GridView City = e.Equals(GridCity)为GridView;

// GridState.DataSource = getData(sQuery);
// GridState.DataBind();

}

}

解决方案

不知道你尝试了什么(因为你没有告诉我们) ,但请查看 asp gridview自动增量列 - Google搜索 [ ^ ]。

I want to generate nested grid view from grid view row add button.if i click add button nested grid view have to be generate based on parent grid ID.

For example parent grid id=1 means while clicking add nested grid row have to be generated with auto increment ID while each time clicking add button(like 1.1,1.2) If second row from parent grid means 2.1,2.2 like this have to create in nested grid row id

What I have tried:

while clicking add in grid view row:
using two tables while concatenating 1.1,1.2 for first row.if i add in second row it showing 2.3 how to solve. using data table is easy means how to do it?

protected void OnSelectedIndexChanged(object sender, EventArgs e)
     {

         string Sid = GridState.SelectedRow.Cells[1].Text;
         SqlConnection con = new SqlConnection(conString);
         {
             using (SqlCommand cmd = new SqlCommand("INSERT INTO City  VALUES('" + TextBox3.Text + "' , '" + TextBox4.Text + "' , '" + TextBox5.Text+"' , " + Sid+")", con))
             {

                 con.Open();
                 cmd.ExecuteNonQuery();
                 con.Close();

                 string sQuery1 = "SELECT CAST(S_id AS VARCHAR(20) ) +'.'+ CAST(City_id AS VARCHAR(20) ),City_code,City_name from City where S_id="+Sid;
                 string value=getData1(sQuery1).ToString();
                 //string sQuery = "SELECT CAST(S_id AS VARCHAR(20) ) +'.'+ CAST(City_id AS VARCHAR(20) ),City_code,City_name from City";
                 ////GridView City = e.Equals("GridCity") as GridView;

                 //GridState.DataSource = getData(sQuery);
                 //GridState.DataBind();

             }

         }

解决方案

No idea what you tried (as you did not tell us), but take a look at asp gridview auto increment column - Google Search[^].


这篇关于如何从父网格行ID生成ID,如1.1,1.2.in嵌套网格视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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