0

//Bedlow は、ページの読み込みに動的コントロールを追加するための page_load コードです。page_load gvSecond の動的テンプレート フィールドのロードが追加されます。各ポストバック値にドットが追加される理由を知りたい

 protected void Page_Load(object sender, EventArgs e)
    {

        gvFirst.DataSource = GetData("select top 10 * from Project_Master");
        gvFirst.DataBind();
}
//gvFirst has gvSecond and on rowdatabound of the gvFirst gvSecond populated with dynamic template fields. and all the template fields has the TextBoxtes in it 


protected void gvFirst_OnRowDataBound(object sender, GridViewRowEventArgs e)
{
    //below  code to generate dynamic template column    
    gvFirst.DataSource = GetData("select top 10 * from Project_Master");
                    gvFirst.DataBind();
            //Added dynamic controls in gvSecond
             protected void gvFirst_OnRowDataBound(object sender, GridViewRowEventArgs e)
                {
                    if (e.Row.RowType == DataControlRowType.DataRow)
                    {
                        string customerId = gvFirst.DataKeys[e.Row.RowIndex].Value.ToString();
                        GridView gvSecond = e.Row.FindControl("gvSecond") as GridView;
                        DataTable dt= GetData1(Convert.ToInt32(customerId));
                        foreach (DataColumn col in dt.Columns)
                        {
                            //Declare the bound field and allocate memory for the bound field.
                            TemplateField bfield = new TemplateField();

                            //Initalize the DataField value.
                            bfield.HeaderTemplate = new GridViewTemplate(ListItemType.Header, col.ColumnName);


                            //Initialize the HeaderText field value.
                            bfield.ItemTemplate = new GridViewTemplate(ListItemType.Item, col.ColumnName);


                            //Add the newly created bound field to the GridView.
                            gvSecond.Columns.Add(bfield);
                        }
                        TotalColumns = dt.Columns.Count;

                        gvSecond.DataSource = dt; 
                        gvSecond.DataBind();
                    }
                }
}
//This is used to add the dynamic template in gvSecond.Now when I click on button textbox values appended with postback values and older values seperated by dot(.)
4

1 に答える 1