473,397 Members | 1,949 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,397 software developers and data experts.

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_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DgrdRunning.ItemCreated
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = _
ListItemType.AlternatingItem Then
'always insert the dataelement name into the first column as a
label.
Dim MyControl As Control =
LoadControl("..\Common\UserDateControl.ascx")
e.Item.Cells(0).Controls.Add(MyControl )
MyControl .ID = "MyUserControl"
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.Items
Dim MyDate as string
MyDate = CType (Item.Cells(0).FindControl("MyUserControl"),
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 1428

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

Similar topics

8
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"...
0
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...
0
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...
0
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...
1
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...
2
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...
1
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...
2
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...
4
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.