By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,180 Members | 1,144 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,180 IT Pros & Developers. It's quick & easy.

Getting row number in User Control that place inside DataGrid

P: 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 ?

Nov 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.