Click here to Skip to main content
15,891,136 members
Home / Discussions / C#
   

C#

 
GeneralRe: Concatenating 2 string arrays Pin
Jeremy Kimball29-Oct-03 1:48
Jeremy Kimball29-Oct-03 1:48 
GeneralRe: Concatenating 2 string arrays Pin
Jeff Varszegi30-Oct-03 14:46
professionalJeff Varszegi30-Oct-03 14:46 
QuestionHow to take input in a password file? Pin
Anonymous28-Oct-03 20:07
Anonymous28-Oct-03 20:07 
AnswerRe: How to take input in a password field? Pin
Anonymous28-Oct-03 20:09
Anonymous28-Oct-03 20:09 
AnswerRe: How to take input in a password file? Pin
Heath Stewart29-Oct-03 11:27
protectorHeath Stewart29-Oct-03 11:27 
QuestionHow to thread? Pin
Anonymous28-Oct-03 18:39
Anonymous28-Oct-03 18:39 
AnswerRe: How to thread? Pin
Jeremy Kimball29-Oct-03 2:00
Jeremy Kimball29-Oct-03 2:00 
GeneralPosting back datagrid web control values Pin
Ismael Chivite28-Oct-03 17:04
Ismael Chivite28-Oct-03 17:04 
Do anyone know how to get back from the client the values of a data grid when columns have been added dinamically?

I noticed that if the AutoGenerateColumns flag is set to true and a dataset is binded to the DataGrid, postbacks include all the cells, even when the user changed values. This allows to add editing capabilities by traping the Update and Edit events.
However, if the columns are added dinamically (let's say template columns need to be used), no columns appear on the postback. See code below.

Notice that this part of the code

// BoundColumn pDBColumn = new BoundColumn();
// pDBColumn.DataField = "ARTIST";
// pDBColumn.HeaderText = "ARTIST2";

// DataGrid1.Columns.Add (pDBColumn);

adds a column dinamically. The column gets added to the response, but is missing on the client's request.

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace TemplateColumns
{
///
/// Summary description for WebForm1.
///

public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label LblDebug;
protected System.Web.UI.WebControls.DataGrid DataGrid1;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (!IsPostBack)
{
DataGridBind();
}

}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.DataGrid1.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_EditCommand);
this.DataGrid1.UpdateCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_UpdateCommand);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void DataGridBind()
{

// BoundColumn pDBColumn = new BoundColumn();
// pDBColumn.DataField = "ARTIST";
// pDBColumn.HeaderText = "ARTIST2";

// DataGrid1.Columns.Add (pDBColumn);

// Simple bind to a TextBox control


if (Session["TheDataset"] == null)
{
DataSet pDS0 = new DataSet("EmployeesDataSet");
pDS0.ReadXml(@"c:\cd_catalog.xml");
Session["TheDataset"] = pDS0;
}
DataSet pDS = Session["TheDataset"] as DataSet;
DataGrid1.DataSource = pDS;

DataGrid1.DataBind();


}

private void DataGrid1_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
DataGrid1.SelectedIndex = e.Item.DataSetIndex;
DataGrid1.EditItemIndex = DataGrid1.SelectedIndex;
this.LblDebug.Text = "Cells on DataGrid1_EditCommand: " + e.Item.Cells.Count.ToString();
DataGridBind();
}

private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
this.LblDebug.Text = "Cells on DataGrid1_UpdateCommand: " + e.Item.Cells.Count.ToString();
DataGridBind();
}
}
}
GeneralStringBuilder, byte[], lpstr, interop Pin
Tym!28-Oct-03 14:18
Tym!28-Oct-03 14:18 
GeneralRe: StringBuilder, byte[], lpstr, interop Pin
Jeremy Kimball29-Oct-03 1:40
Jeremy Kimball29-Oct-03 1:40 
GeneralRe: StringBuilder, byte[], lpstr, interop Pin
Tym!29-Oct-03 6:28
Tym!29-Oct-03 6:28 
GeneralRe: StringBuilder, byte[], lpstr, interop Pin
Tym!29-Oct-03 14:12
Tym!29-Oct-03 14:12 
GeneralRenaming a File Pin
deanoA28-Oct-03 14:09
deanoA28-Oct-03 14:09 
GeneralRe: Renaming a File Pin
Nick Parker28-Oct-03 14:21
protectorNick Parker28-Oct-03 14:21 
GeneralSuper Lame QOTD (Stripping Paths) Pin
MKlucher28-Oct-03 11:56
MKlucher28-Oct-03 11:56 
GeneralRe: Super Lame QOTD (Stripping Paths) Pin
Kentamanos28-Oct-03 12:25
Kentamanos28-Oct-03 12:25 
GeneralRe: Super Lame QOTD (Stripping Paths) Pin
MKlucher28-Oct-03 12:40
MKlucher28-Oct-03 12:40 
GeneralRe: Super Lame QOTD (Stripping Paths) Pin
Kentamanos28-Oct-03 12:43
Kentamanos28-Oct-03 12:43 
GeneralRe: Super Lame QOTD (Stripping Paths) Pin
Heath Stewart28-Oct-03 16:40
protectorHeath Stewart28-Oct-03 16:40 
GeneralRe: Super Lame QOTD (Stripping Paths) Pin
Kentamanos29-Oct-03 5:46
Kentamanos29-Oct-03 5:46 
GeneralRe: Super Lame QOTD (Stripping Paths) Pin
James Simpson30-Oct-03 5:10
James Simpson30-Oct-03 5:10 
GeneralRe: Super Lame QOTD (Stripping Paths) Pin
Nick Parker28-Oct-03 14:27
protectorNick Parker28-Oct-03 14:27 
GeneralRe: Super Lame QOTD (Stripping Paths) Pin
Heath Stewart28-Oct-03 16:42
protectorHeath Stewart28-Oct-03 16:42 
GeneralBlocking move of a form Pin
phimix28-Oct-03 6:54
phimix28-Oct-03 6:54 
GeneralRe: Blocking move of a form Pin
Blake Coverett28-Oct-03 7:45
Blake Coverett28-Oct-03 7:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.