I am trying to loop through a grid and replace some values in certain cells. I am basically taking values from a text box, matching it to values in the grid and replacing those values with the value in another text box. I can do this without any issue using a standard GridView. How do I do this with RadGrid. RadGrid seems to not have a Rows object.
Here is my code that works fine with a GridView:
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Telerik.Web.UI;
public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
GenerateUniqueData(3);
}
private void GenerateUniqueData(int name)
{
string initialnamevalue = this.TextBox1.Text;
for (int i = 1; i < GridView1.Rows.Count; i++)
{
if (GridView1.Rows[i].Cells[name].Text == initialnamevalue)
GridView1.Rows[i].Cells[name].Text = this.TextBox2.Text;
else
initialnamevalue = GridView1.Rows[i].Cells[name].Text;
}
}
}
Here is my code that works fine with a GridView:
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Telerik.Web.UI;
public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
GenerateUniqueData(3);
}
private void GenerateUniqueData(int name)
{
string initialnamevalue = this.TextBox1.Text;
for (int i = 1; i < GridView1.Rows.Count; i++)
{
if (GridView1.Rows[i].Cells[name].Text == initialnamevalue)
GridView1.Rows[i].Cells[name].Text = this.TextBox2.Text;
else
initialnamevalue = GridView1.Rows[i].Cells[name].Text;
}
}
}