473,657 Members | 2,953 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

User Control in Datagrid without TemplateColumn

Hi all,

Have a question from the following post to create user control in a
Datagrid....

http://www.dotnet247.com/247referenc...45/225337.aspx

I have a question.... I can create the User control in the Datagrid... and
that is a run time user control in the datagrid.. without using the
<templatecolumn > in the datagrid... and on ItemCreated Event i create the
user control in the datagrid.

Now if i want to get the value out of the datagrid on a button click how m i
supose to get as when i say

Below is the code to add a user control in the cell (0).... of my datagrid
at runtime
Private Sub DgrdRunning_Ite mCreated(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Data GridItemEventAr gs) Handles
DgrdRunning.Ite mCreated
If e.Item.ItemType = ListItemType.It em Or e.Item.ItemType = _
ListItemType.Al ternatingItem Then
'always insert the dataelement name into the first column as a
label.
Dim MyControl As Control =
LoadControl(".. \Common\UserDat eControl.ascx")
e.Item.Cells(0) .Controls.Add(M yControl )
MyControl .ID = "MyUserCont rol"
MyControl .value= e.Item.Cells(0) .Text
End If
End sub
Here is the code to get the value out of the datagrid's user contro which i
added...

For Each Item As DataGridItem In DgrdRunning.Ite ms
Dim MyDate as string
MyDate = CType (Item.Cells(0). FindControl("My UserControl"),
UserDateControl ).value
Next
It doesnt give me the new value which a user has input on the user
control..and it gives me a error that object ref. not set to an instance...

But if do it using the templatecolumn then it gets the new value... dont
know what i m doing wrong...

May be i might be wrong... Somewhere

Plz Help

Cheers
C

Nov 19 '05 #1
0 1439

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

Similar topics

8
2328
by: Gilles T. | last post by:
How I can get element ID in the edit mode of datagrid control? If I not in the edit mode, there are no problem. <asp:TemplateColumn ItemStyle-CssClass="grid_column_width_3" ItemStyle-HorizontalAlign="center" ItemStyle-VerticalAlign="top"> <ItemTemplate><%# CType(Container.DataItem("DateStatut"),DateTime).ToString("yyyy-MM-dd") %></ItemTemplate> <EditItemTemplate> <asp:TextBox width="80" CssClass="edit_item" id="txtDateStatut"
0
4786
by: Shane O. Pinnell | last post by:
I am sure this has come up before, but I haven't been able to find an answer as of yet. That said, any help is definitely appreciated! I have a datagrid populated from a dataset. I have a TemplateColumn with a DropDownList (DDL) in the FooterItemTemplate that is populated in the Page_Load event using a Sub Routine as the DataSource of the DDL. The FooterItemTemplate's DDL populates as expected when the DataGrid's DataBind method is called. ...
0
1428
by: Oleg G. | last post by:
Hi there! I have datagrid with template column and I am using the same user control for display (in ItemTemplate) and collect (in EditItemTemplate) information. The user control is a number of text boxes basically in this case. But when I put some values into this control (LinksData2) and go back to the server I am not able to pick up the data from the control (LinksData2). It seems it's not stored in ViewState at all. In the same time if...
0
1925
by: Zi | last post by:
I have a user control within a data grid. I am binding the user control to one of the values from the data grid. The data grid implements paging. It is all working ok for the first page but once i page to the second page of the datagrid, the user contorl stops working correctly (displaying the correct data). I have attached the code that is envolved. Thanks a lot
1
10927
by: bill yeager | last post by:
I have a datagrid control within a datalist control. When I try and do a "Find" on the control, the object comes back with nothing and then my pgm crashes. I am 100% sure that my datagird inside my datalist has an id of "Datagrid3". dgChild comes back with "Nothing" while debugging. Here is my code in the itemdatabound event for the datalist: <code>
2
3162
by: Josh | last post by:
Hi Guys, I have been stuck on this problem for several days now, i have a set of nested datagrids. Inside the second datagrid i have a dropdown list, a textbox and a label. I want the textbox to update the label with the value of the dropdown list * the text box quantity. I am using an onTextChaged even on the textbox, the problem i have is that i can not find the lblPrice control. Thanks for the help,
1
5843
by: Raed Sawalha | last post by:
i have aspx page with user control containing a datagrid , the datagrid has TempleteColumn with checkbox in header and item ( doing multiselect task) I wondering how Can get the checkboxes status from aspx page this is my datagrid in the user control <asp:datagrid id="dgFoldersInfo" runat="server" BorderColor="Black" BorderWidth="0px" HeaderStyle-CssClass="tableHeaderCell" ShowFooter="True" CellPadding="3" GridLines="Horizontal"...
2
3224
by: tshad | last post by:
This is related to my other Hiding datalistitems problem that I can't seem to solve. I have tried different methods which all seem to work only partially. I decided to try to use a User Control (which I'm sure is not done correctly) and get errors as I try to execute it. What I want to do is take all the data from between the ItemTemplate tags and put a control there. The I hope to be able to hide all the user
4
1729
by: glenn | last post by:
Hi folks, I am getting an error "Object reference not set to an instance of an object". It seems I have everything in place but something is obviously in err. If you could take a quick peak at my code segments and provide any insight in a reply, I would be eternally grateful. My table name is "rfi" and the field with a dropdownlist control is called "contract". I have imported the System.Data and System.Data.OleDb libraries. ...
0
8384
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
8820
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
8718
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
8601
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
7314
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...
0
5630
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();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1937
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1601
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.