473,396 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Change value of DataGrid columns


I'm looking into this peace of code:

protected void DropDown_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList list = (DropDownList)sender;

TableCell cell = list.Parent as TableCell;
DataGridItem item = cell.Parent as DataGridItem;

int index = item.ItemIndex;
string content = item.Cells[0].Text;

Response.Write(
String.Format("Row {0} contains {1}", index, content)
);

}

can I do this:

item.Cells[0].Text = "Some text...";

I don't want only to change value in the grid (displayed value), but also in
the underlaying DataSource (which is of XML file type).
Jun 5 '06 #1
3 2094
This is too early in the page processing life cycle to change the cell
text. You'll have to change it in the Page.PreRender or later in the
page life cycle.

If you change the cell text, or pretty much any object in the datagrid,
at this point it is still "vulnerable" to changes being made to it by
the asp.net framework during round trip processing.

Curtis

John Smith wrote:
I'm looking into this peace of code:

protected void DropDown_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList list = (DropDownList)sender;

TableCell cell = list.Parent as TableCell;
DataGridItem item = cell.Parent as DataGridItem;

int index = item.ItemIndex;
string content = item.Cells[0].Text;

Response.Write(
String.Format("Row {0} contains {1}", index, content)
);

}

can I do this:

item.Cells[0].Text = "Some text...";

I don't want only to change value in the grid (displayed value), but also in
the underlaying DataSource (which is of XML file type).


Jun 5 '06 #2
You can always rebind the grid to a different datasource.
"John Smith" <jo********@microsoft.com> wrote in message
news:qR********************@news.siol.net...

I'm looking into this peace of code:

protected void DropDown_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList list = (DropDownList)sender;

TableCell cell = list.Parent as TableCell;
DataGridItem item = cell.Parent as DataGridItem;

int index = item.ItemIndex;
string content = item.Cells[0].Text;

Response.Write(
String.Format("Row {0} contains {1}", index, content)
);

}

can I do this:

item.Cells[0].Text = "Some text...";

I don't want only to change value in the grid (displayed value), but also
in the underlaying DataSource (which is of XML file type).

Jun 5 '06 #3

Will this line of the code:

item.Cells[0].Text = "Some text...";

change only DataGrid visual value or it will also change value in the
DataSource? How can I change value in DataSource?

"Curtis" <cu**********@hotmail.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
This is too early in the page processing life cycle to change the cell
text. You'll have to change it in the Page.PreRender or later in the
page life cycle.

If you change the cell text, or pretty much any object in the datagrid,
at this point it is still "vulnerable" to changes being made to it by
the asp.net framework during round trip processing.

Curtis

John Smith wrote:
I'm looking into this peace of code:

protected void DropDown_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList list = (DropDownList)sender;

TableCell cell = list.Parent as TableCell;
DataGridItem item = cell.Parent as DataGridItem;

int index = item.ItemIndex;
string content = item.Cells[0].Text;

Response.Write(
String.Format("Row {0} contains {1}", index, content)
);

}

can I do this:

item.Cells[0].Text = "Some text...";

I don't want only to change value in the grid (displayed value), but also
in
the underlaying DataSource (which is of XML file type).

Jun 6 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Amber | last post by:
There are times when you will need to highlight or otherwise modify the contents of a particular DataGrid row-column value based upon the value in the column. In this example we will select the...
0
by: Dan Hartshorn | last post by:
VS.NET 2003, C#, Windows Server 2003. I have a datagrid and I want the last column to be either an EditCommandColumn or a template column, depending on a value I have. The value changes for each...
0
by: Andy Wang | last post by:
I need change HeaderText of DataGrid in PreRender(). But it seems doesn't work. The code example like this: Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)...
3
by: Miguel Dias Moura | last post by:
Hello, i know how to hide a table according to a condition: <table runat="server" visible='<%# dataSetBibliotecas.FieldValue("Titulo", Container) <> "" %>'... Now I am trying to change the...
4
by: Rob Kroese | last post by:
I've got a form with a datagrid that displays a list of items, along with several textboxes, comboboxes, etc., that display the details for the selected item. The columns in the datagrid and the...
1
by: Michael via .NET 247 | last post by:
I have a datagrid with the columns defined in the aspx <columns> <asp:TemplateColumn HeaderText="Hours" ItemStyle-Width="1%"ItemStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:TextBox...
0
by: zhuang | last post by:
Hi, Adding combobox to datagrid has been posted many times. I have a datagrid which has multiple combobox columns and normal textbox columns. But how could I change other combo box values at...
2
by: John Smith | last post by:
Will this line of the code: item.Cells.Text = "Some text..."; change only DataGrid visual value or it will also change value in the DataSource? How can I change value in DataSource? ...
2
by: remya1000 | last post by:
i'm using VB.NET. and its a windows application. in my program i need to display a table in datagrid. so i created the table using DataTable and i'm calling that dataTable to dataGrid. and its...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.