473,387 Members | 1,766 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,387 software developers and data experts.

Change value of DataGrid columns (2)


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 #1
2 2237

This is what I am trying now, but it doesn't work. I'm not sure even if
event triggers.

Public Sub DropDown_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles DataGrid1.SelectedIndexChanged
Dim list As DropDownList = CType(sender, DropDownList)
Dim cell = CType(list.Parent, TableCell)
Dim item = CType(cell.Parent, DataGridItem)
Dim index = item.ItemIndex
DataGrid1.EditItemIndex = item.ItemIndex
Dim id As Integer = Convert.ToInt32(item.Cells(1).Text)
Dim ds As DataSet
ds = DataGrid1.DataSource
Dim RowUredi As DataRow
RowUredi = ds.Tables(0).Select("ID = '" + id.ToString + "'")(0)
RowUredi.Item(6) = "P"
RowUredi.AcceptChanges()
End Sub

What should I do?
Jun 6 '06 #2
Only the visual value. You can refer to datasource as item.DataItem, but I
am not sure modifying the datasource from the grid events is a good idea.

Eliyahu

"John Smith" <jo********@microsoft.com> wrote in message
news:UV********************@news.siol.net...

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 #3

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...
3
by: John Smith | last post by:
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...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.