Click here to Skip to main content
15,910,773 members
Home / Discussions / C#
   

C#

 
QuestionThe value DataGridViewRow.Tag is lost after sorting Pin
Michael Sync10-Oct-07 21:01
Michael Sync10-Oct-07 21:01 
I'm facing one problem with DataGridViewRow.Tag. I set some values to DataGridViewRow.Tag. Then, I get those values whenever it is necessary. but when I do sorting the GridView by clicking the header of Girdview, all values which was set are gone...

The following is my sample code..

Filling the data to DataView

private void Form1_Load(object sender, EventArgs e)<br />
        {<br />
            // TODO: This line of code loads data into the 'employeeMgmtDataSet.Employees' table. You can move, or remove it, as needed.<br />
            this.employeesTableAdapter.Fill (this.employeeMgmtDataSet.Employees);<br />
<br />
        }


Setting the value to DataGridViewRow.Tag
private void button1_Click(object sender, EventArgs e)<br />
        {<br />
            <br />
            foreach ( DataGridViewRow dr in dataGridView1.Rows )<br />
            {<br />
               dr.Tag   = "Michael Sync";<br />
            }<br />
        }


Getting the value from DataGridViewRow.Tag
private void button2_Click(object sender, EventArgs e)<br />
       {<br />
           foreach ( DataGridViewRow dr in dataGridView1.Rows )<br />
           {<br />
               Console.WriteLine (dr.Tag.ToString ());<br />
           }<br />
       }


it works fine before sorting.. but Tag become "null" after sorting.. Why is it happening like that?

Any idea would be appreciated. Thanks in advance..



Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)

AnswerRe: The value DataGridViewRow.Tag is lost after sorting Pin
TJoe11-Oct-07 3:07
TJoe11-Oct-07 3:07 
QuestionToolStripMenuItem with ContextMenuStrip Pin
User 269896710-Oct-07 21:00
User 269896710-Oct-07 21:00 
AnswerRe: ToolStripMenuItem with ContextMenuStrip Pin
half-life10-Oct-07 21:21
half-life10-Oct-07 21:21 
GeneralRe: ToolStripMenuItem with ContextMenuStrip Pin
User 269896710-Oct-07 21:49
User 269896710-Oct-07 21:49 
GeneralRe: ToolStripMenuItem with ContextMenuStrip Pin
half-life10-Oct-07 21:53
half-life10-Oct-07 21:53 
GeneralRe: ToolStripMenuItem with ContextMenuStrip Pin
User 269896710-Oct-07 22:01
User 269896710-Oct-07 22:01 
GeneralRe: ToolStripMenuItem with ContextMenuStrip Pin
half-life10-Oct-07 22:07
half-life10-Oct-07 22:07 
QuestionThreads Pin
half-life10-Oct-07 20:56
half-life10-Oct-07 20:56 
AnswerRe: Threads Pin
Anthony Mushrow10-Oct-07 21:17
professionalAnthony Mushrow10-Oct-07 21:17 
GeneralRe: Threads Pin
half-life10-Oct-07 21:23
half-life10-Oct-07 21:23 
QuestionRegarding DIV Pin
Satish_S10-Oct-07 20:48
Satish_S10-Oct-07 20:48 
QuestionLoading data to SQL Server from .csv file Pin
Aswini Kumar10-Oct-07 20:29
Aswini Kumar10-Oct-07 20:29 
AnswerRe: Loading data to SQL Server from .csv file Pin
Rob Philpott10-Oct-07 22:22
Rob Philpott10-Oct-07 22:22 
QuestionCan I Get File Extension(openfiledialog) Pin
chanzeb10-Oct-07 20:17
chanzeb10-Oct-07 20:17 
AnswerRe: Can I Get File Extension(openfiledialog) Pin
Giorgi Dalakishvili10-Oct-07 20:19
mentorGiorgi Dalakishvili10-Oct-07 20:19 
GeneralRe: Can I Get File Extension(openfiledialog) Pin
aswini10-Oct-07 20:23
aswini10-Oct-07 20:23 
GeneralRe: Can I Get File Extension(openfiledialog) Pin
Giorgi Dalakishvili10-Oct-07 20:25
mentorGiorgi Dalakishvili10-Oct-07 20:25 
AnswerRe: Can I Get File Extension(openfiledialog) Pin
Spunky Coder10-Oct-07 20:36
Spunky Coder10-Oct-07 20:36 
Questionmsdn and visual studio.net 2005 Pin
tieuquai198710-Oct-07 20:13
tieuquai198710-Oct-07 20:13 
AnswerRe: msdn and visual studio.net 2005 Pin
TJoe11-Oct-07 3:04
TJoe11-Oct-07 3:04 
QuestionWPF Database connection acrchitecture Pin
Alan Boldock10-Oct-07 19:54
Alan Boldock10-Oct-07 19:54 
Questionto read the file name help me plz..... Pin
P_Elza10-Oct-07 19:19
P_Elza10-Oct-07 19:19 
AnswerRe: to read the file name help me plz..... Pin
Charith Jayasundara10-Oct-07 19:30
Charith Jayasundara10-Oct-07 19:30 
AnswerRe: to read the file name help me plz..... Pin
aswini10-Oct-07 20:26
aswini10-Oct-07 20:26 

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.