473,656 Members | 2,762 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Cont rol)DataGrid1.I tems[i].FindControl(th is.ID)).Equals( sender))
{
desc_obj =
((TextBox)DataG rid1.Items[i].FindControl(ex t_desc)).Client ID;
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(objec t sender, System.EventArg s e)
{
DataRow dr ;
DataTable dt = new DataTable();
dt.Columns.Add( new DataColumn("ite m_attr_x_code", typeof(string)) );
for (int i = 0; i < color.Items.Cou nt; i++)
{
dr = dt.NewRow();
dr[0] =
((Common.Color_ Control)DataGri d1.Items[i].FindControl("C olor_Control_gr id")).Code;
dt.Rows.Add(dr) ;
}

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

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 1381

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

Similar topics

9
1911
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 could probably do a byref to pass it into one of the subs, but I heard that was not effecient... MyDataGrid.CurrentPageIndex += 1
3
2750
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. --- Posted using Wimdows.net NntpNews Component -
2
2203
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 "PlaceHolder" control "ph" in the user control; 2. create a Label control and TextBox control when in the "add" button
6
2183
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 on the footer. At the moment, I go through the dataListItems like so: for each oItem as DataListItem in DataList1.Items trace.warn("inside for loop oItem type = " & oItem.itemType.ToString())
15
10984
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
1270
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 dept_value; } All the values were added via the visual interface.
1
2036
by: margant | last post by:
Dear Professionals, I have placed my datagrid : .... <asp:Datagrid ID="DGEdu" runat="server" OnDeleteCommand="DGEdu_Remove" OnItemDataBound="DGEdu_ItemDataBound" OnItemCommand="DGEdu_OnItemCommand" AutoGenerateColumns="false"
1
1053
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 code: Calling code from the page that contains the control: ----
0
2123
by: JohnyStyles | last post by:
I have a templated user control which looks like this: ----------------------------------------------------------------- <uc:MyUserControl runat=server> <TemplateProperty> </TemplateProperty> </uc:MyUserControl> -----------------------------------------------------------------
0
8382
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8297
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8717
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8600
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7311
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5629
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.