I am rendering my grid on pre-render... i am writing this code on selected index change event of my radiobutton within the gridview...after the grid has been renedered if I select "Yes" for the radiobutton I want to show the child row of the gridview and
if we select "No" I want to hide the gridview row... I have the value of the child control column... Now i want to loop through the gridview rows and columns and match that value and return the rowIndex so i can hide the entire row of gridview...
asp.netUser
Member
15 Points
184 Posts
whats wrong with my code?
May 01, 2012 08:25 AM|LINK
I dont get any cell value in the code below for this statement : gvDynamicControl.Rows[1].Cells[6].ToString()
I wont to compare the gridview cell value and return the rowindex
for (int rowIndex = 0; rowIndex < gv.Rows.Count; rowIndex++)
{
for (int columnIndex = 0; columnIndex < gv.Columns.Count; columnIndex++)
{
if (gvDynamicControl.Rows[1].Cells[6].ToString() =="Test")
Session["rowIndex"] = rowIndex;
}
}
HeartattacK
All-Star
55262 Points
5917 Posts
Moderator
MVP
Re: whats wrong with my code?
May 01, 2012 08:31 AM|LINK
No idea what your code does, but shouldn't it look like:
if(gvDynamicControl.Rows[rowIndex].Cells[columnIndex].ToString() == "Test)
...
blog: www.heartysoft.com
twitter: @ashic
asp.netUser
Member
15 Points
184 Posts
Re: whats wrong with my code?
May 01, 2012 08:34 AM|LINK
I want to compare the cell/column value of a gridview and return the rowindex...how can i achieve that ?
Bhavik Solu...
Member
746 Points
159 Posts
Re: whats wrong with my code?
May 01, 2012 08:44 AM|LINK
Hi,
Here is simple code for get data from datagrid and grid view
protected void btnGetData_Click(object sender, EventArgs e) { string subjectName = string.Empty; int Subjectid = 0; //get data from datagrid subjectName = grdgrid.Items[0].Cells[0].Text; int.TryParse(grdgrid.Items[0].Cells[1].Text,out Subjectid); //get data from gridview subjectName=grdview.Rows[0].Cells[0].Text; int.TryParse(grdview.Rows[0].Cells[1].Text, out Subjectid); }now can you tell me in which event you are writing code means like grid view itemcommand,prerender etc
asp.netUser
Member
15 Points
184 Posts
Re: whats wrong with my code?
May 01, 2012 08:47 AM|LINK
I am rendering my grid on pre-render... i am writing this code on selected index change event of my radiobutton within the gridview...after the grid has been renedered if I select "Yes" for the radiobutton I want to show the child row of the gridview and if we select "No" I want to hide the gridview row... I have the value of the child control column... Now i want to loop through the gridview rows and columns and match that value and return the rowIndex so i can hide the entire row of gridview...
rafemuhammed
Member
302 Points
97 Posts
Re: whats wrong with my code?
May 01, 2012 08:49 AM|LINK
http://forums.asp.net/t/1477232.aspx
rafes.net