Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Getting row number in User Control that place inside DataGrid

Thread Tools

Getting row number in User Control that place inside DataGrid

John Shum
Posts: n/a
I prepare a UserControl that act as a lookup control, once the code is
enter in the TextBox, the description will appear in another TextBox
outside the UserControl of the same row in a DataGrid via javascript.

I attempt to get the client ID of the TextBox (with provided ID of that
TextBox as "ext_desc") by the following code inside the Page_Load()
event of the UserControl (named Color_Control):

for(int i = 0; i < DataGrid1.Items.Count; i++)

desc_obj =

desc_obj should get the ClientID of the TextBox.
It run okay when I run the page at first time, but when I write a code
to append some empty rows inside the DataGrid again, it fail to get the
number of Control, the code for adding empty rows is as follow:

// In the Page that the User Control located
private void Add_Click(object sender, System.EventArgs e)
DataRow dr ;
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("item_attr_x_code", typeof(string)));
for (int i = 0; i < color.Items.Count; i++)
dr = dt.NewRow();
dr[0] =

for (int k=1; k <= 5; k++)
dr = dt.NewRow();
dr[0] = "";
DataGrid1.DataSource = dsX;

It seems that after the above function is executed, the
DataGrid1.Items.Count inside the Page_Load Event of the UserControl
fail to get the correct Items.Count.

May I know if there is any work around on the case, or I start from a
wrong approach ?

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing USER CONTROL which is inside Masterpagethrough Another USER Control inside normal page. Kiran More ASP .Net Web Controls 2 11-14-2006 12:58 PM
ok I can do a totals row but how about a percentage row after each data row D ASP .Net Datagrid Control 0 05-23-2005 04:10 PM
Make a DataGrid row editable after user selects the row Luis Esteban Valencia ASP .Net 0 01-12-2005 05:59 PM
getting the row number in a datagrid 2obvious ASP .Net 2 12-31-2004 03:49 AM
Event not firing for user control inside user control vatech1993 ASP .Net 4 12-11-2004 02:51 PM