473,396 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Getting row number in User Control that place inside DataGrid

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++)
{

if(((Color_Control)DataGrid1.Items[i].FindControl(this.ID)).Equals(sender))
{
desc_obj =
((TextBox)DataGrid1.Items[i].FindControl(ext_desc)).ClientID;
break;
}
}

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] =
((Common.Color_Control)DataGrid1.Items[i].FindControl("Color_Control_grid")).Code;
dt.Rows.Add(dr);
}

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

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
0 1359

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Max | last post by:
How do I reference a datagrid on a page from a user control on that page? In my user control, I'd like to have something like this... MyDataGrid being on the page, not in the user control... I...
3
by: DotNetJunkies User | last post by:
Hi , I hav a buttoncolumn(pushBackButton) in my datagrid. And on click of every button i want to call different methods(server side). Kindly help me out..!!!!!!!! Thnx, Rameshwar,Govindu. ...
2
by: Quentin Huo | last post by:
Hi: I have a user control and I want to dynamically create a Label control and TextBox control when the button "add more author name" is clicked. I did like this: 1. there is a...
6
by: tshad | last post by:
I need to get to a status label I have on my footer section of my datalist. There is no event happening that would go to the footer. I am just doing some processing and want to update the label...
15
by: dee | last post by:
Hi, What is the maximum number of minutes for Session timeout that I can specify in web.config? Thanks. Dee
3
by: Moojjoo | last post by:
I created an user control (.ascx file) with a DropDownList (DDL) with the following code behide: public string Selected_dept_value() { string dept_value = dept_dropdown.SelectedValue; return...
1
by: margant | last post by:
Dear Professionals, I have placed my datagrid : .... <asp:Datagrid ID="DGEdu" runat="server" OnDeleteCommand="DGEdu_Remove" OnItemDataBound="DGEdu_ItemDataBound"...
1
by: Ryan Ternier | last post by:
I'm playing around with a user control that I think might help one of my projects. I'm having an issue with it retaining the controls inside a placeholder that are added dynamically. Here's the...
0
by: JohnyStyles | last post by:
I have a templated user control which looks like this: ----------------------------------------------------------------- <uc:MyUserControl runat=server> <TemplateProperty> </TemplateProperty>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.