problem in tranfer the value of one gridView cell into another gridview textbox
-
hello all, I want to get a value from gridView (grdQuestions) which in turn goes to the textbox which is in another grdView(grdOptions). Now, the problem is how to find the control of textBox(txtText) of "GrdOptions" GridView, so that i can set the "GrdQuestions" griview cells' value into that textbox... plz help if you understand.. The code is: foreach (GridViewRow rw in GrdQuestions.Rows) { for (int i = 8; i < GrdQuestions.Rows[e.NewEditIndex].Cells.Count; i++) { TextBox tb = (TextBox)GrdOptions.Rows[0].Cells[1].FindControl("txtText"); if (GrdQuestions.Rows[rw.RowIndex].Cells[i].Text != string.Empty) { tb.Text = GrdQuestions.Rows[rw.RowIndex].Cells[i].Text; } } }
-
hello all, I want to get a value from gridView (grdQuestions) which in turn goes to the textbox which is in another grdView(grdOptions). Now, the problem is how to find the control of textBox(txtText) of "GrdOptions" GridView, so that i can set the "GrdQuestions" griview cells' value into that textbox... plz help if you understand.. The code is: foreach (GridViewRow rw in GrdQuestions.Rows) { for (int i = 8; i < GrdQuestions.Rows[e.NewEditIndex].Cells.Count; i++) { TextBox tb = (TextBox)GrdOptions.Rows[0].Cells[1].FindControl("txtText"); if (GrdQuestions.Rows[rw.RowIndex].Cells[i].Text != string.Empty) { tb.Text = GrdQuestions.Rows[rw.RowIndex].Cells[i].Text; } } }
have you a link or button to transfer the data of one grid cell value to other?
Regards Keyur Satyadev
-
hello all, I want to get a value from gridView (grdQuestions) which in turn goes to the textbox which is in another grdView(grdOptions). Now, the problem is how to find the control of textBox(txtText) of "GrdOptions" GridView, so that i can set the "GrdQuestions" griview cells' value into that textbox... plz help if you understand.. The code is: foreach (GridViewRow rw in GrdQuestions.Rows) { for (int i = 8; i < GrdQuestions.Rows[e.NewEditIndex].Cells.Count; i++) { TextBox tb = (TextBox)GrdOptions.Rows[0].Cells[1].FindControl("txtText"); if (GrdQuestions.Rows[rw.RowIndex].Cells[i].Text != string.Empty) { tb.Text = GrdQuestions.Rows[rw.RowIndex].Cells[i].Text; } } }
Please use codeblock/code tags while copying code into the question. That will make it easy to read. And please also let me know what exception are you getting and if the grdOptions is binded at the time of this operation.
It is Good to be Important but! it is more Important to be Good
-
have you a link or button to transfer the data of one grid cell value to other?
Regards Keyur Satyadev
I have textbox in another gridview to which value is to be inserted But i don't know how transfer that value into that textbox
-
Please use codeblock/code tags while copying code into the question. That will make it easy to read. And please also let me know what exception are you getting and if the grdOptions is binded at the time of this operation.
It is Good to be Important but! it is more Important to be Good
I just want to know how to get the value of one gridview row into the textbox which is in the template field of another gridview . could you help me in the code?
-
I have textbox in another gridview to which value is to be inserted But i don't know how transfer that value into that textbox
do one thing, when you fire the itemcommand on first gridview at that time take that textbox value in some field (such as if many fields then use the datatable ) and give that datatable to the second grid. i.e. grd2.datasource = dt; grd2.databind() protected void grd1_ItemCommand(object sender, GridCommandEventsArgs e) { if(e.commandname == "settextboxvalue") { string txt1value; txt1value = (TextBox)grd1.FindControl("txt1").Text; } } in this way you get the value of textbox of first grid now you can assign this to the second.
Regards Keyur Satyadev
-
I just want to know how to get the value of one gridview row into the textbox which is in the template field of another gridview . could you help me in the code?
(GrdOptions.Rows[0].FindControl("txtText") as TextBox).Text = GrdQuestions.Rows[rw.RowIndex].Cells[i].Text;
I doubt that its not the way which is causing you problem but its the logic.
It is Good to be Important but! it is more Important to be Good
-
(GrdOptions.Rows[0].FindControl("txtText") as TextBox).Text = GrdQuestions.Rows[rw.RowIndex].Cells[i].Text;
I doubt that its not the way which is causing you problem but its the logic.
It is Good to be Important but! it is more Important to be Good
its not the correct way, how could you populate the row in the statement (GrdOptions.Rows[0].FindControl("txtText") as TextBox) as in that griview, row is empty thus, its giving an error "Index out of range"
-
its not the correct way, how could you populate the row in the statement (GrdOptions.Rows[0].FindControl("txtText") as TextBox) as in that griview, row is empty thus, its giving an error "Index out of range"
vinci007 wrote:
TextBox tb = (TextBox)GrdOptions.Rows[0].Cells[1].FindControl("txtText");
vs
vinci007 wrote:
(GrdOptions.Rows[0].FindControl("txtText") as TextBox)
Doesn't have much difference index out of range!! might have many reasons behind it. 1. your grid GrdOptions is not binded at all. 2. the data source is empty. Please provide more detail what do you want to accomplish - adding some more formatted code will help too.
It is Good to be Important but! it is more Important to be Good