how to Concatenate values from gridview to textbox in asp.net
-
how to Concatenate values from gridview to textbox in asp.net i hav a grid n columns are 3 i use that code if (gvProviderCPTFeeNotesEnterNotes.Rows.Count != 0) { string Str = string.Empty; for (int i = 0; i < gvProviderCPTFeeNotesEnterNotes.Rows.Count; i++) { for(int j=0; j< 3; j++) { string Str1 = gvProviderCPTFeeNotesEnterNotes.Rows[i].Cells[j].Text.ToString(); string Str2 = gvProviderCPTFeeNotesEnterNotes.Rows[i].Cells[j].Text.ToString(); string Str3 = gvProviderCPTFeeNotesEnterNotes.Rows[i].Cells[j].Text.ToString(); if (i == 0) { txtProviderCPTFeeNoteViewNotes.Text = string.Format("Date: {0}\r\nContent: {1}\r\nUserID: {2}", Str1, Str2, Str3); Str = txtProviderCPTFeeNoteViewNotes.Text.ToString(); } else { txtProviderCPTFeeNoteViewNotes.Text = string.Format("{0} \r\n\r\n Date: {1}\r\nContent: {2}\r\nUserID: {3}", Str, Str1, Str2, Str3); Str = txtProviderCPTFeeNoteViewNotes.Text.ToString(); } } } }
-
how to Concatenate values from gridview to textbox in asp.net i hav a grid n columns are 3 i use that code if (gvProviderCPTFeeNotesEnterNotes.Rows.Count != 0) { string Str = string.Empty; for (int i = 0; i < gvProviderCPTFeeNotesEnterNotes.Rows.Count; i++) { for(int j=0; j< 3; j++) { string Str1 = gvProviderCPTFeeNotesEnterNotes.Rows[i].Cells[j].Text.ToString(); string Str2 = gvProviderCPTFeeNotesEnterNotes.Rows[i].Cells[j].Text.ToString(); string Str3 = gvProviderCPTFeeNotesEnterNotes.Rows[i].Cells[j].Text.ToString(); if (i == 0) { txtProviderCPTFeeNoteViewNotes.Text = string.Format("Date: {0}\r\nContent: {1}\r\nUserID: {2}", Str1, Str2, Str3); Str = txtProviderCPTFeeNoteViewNotes.Text.ToString(); } else { txtProviderCPTFeeNoteViewNotes.Text = string.Format("{0} \r\n\r\n Date: {1}\r\nContent: {2}\r\nUserID: {3}", Str, Str1, Str2, Str3); Str = txtProviderCPTFeeNoteViewNotes.Text.ToString(); } } } }
So, are you getting any error or exception with this code? I didn't understand your question, can you explain a bit.
diyaa_08 wrote:
string Str1 = gvProviderCPTFeeNotesEnterNotes.Rows[i].Cells[j].Text.ToString();
Also, no need to use ".ToString()" as ".Text" property returns a string only. P.S: Put your code in "pre" tags, it'll enhance the readability.
-- Modified Wednesday, April 28, 2010 2:03 AM
-
So, are you getting any error or exception with this code? I didn't understand your question, can you explain a bit.
diyaa_08 wrote:
string Str1 = gvProviderCPTFeeNotesEnterNotes.Rows[i].Cells[j].Text.ToString();
Also, no need to use ".ToString()" as ".Text" property returns a string only. P.S: Put your code in "pre" tags, it'll enhance the readability.
-- Modified Wednesday, April 28, 2010 2:03 AM
-
<i displayed values in grid view than in ither tabpanel i hav to display these values in a textbox with concatenation string how i do that plz tell me>
First, tell me whether you want to do this on a particular row selected event or for all rows present in your gridview (Your code is doing this)?