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