CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > visual_studio.visual_studio_2005 Tags:
Item Type: Date Entered: 7/6/2007 2:45:48 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 2 Views: 130 Favorited: 0 Favorite
3 Items, 1 Pages 1 |< << Go >> >|
jvw
Asp.Net User
asxc user control child controls are null7/6/2007 2:45:48 PM

0

 I have an ascx file in my project which loads and displays correct data perfectly. However, when I attempt to write data to the DB from the textboxes nothing happens. Here's some sample:

  

1    <asp:SqlDataSource ID="faxDS" runat="server" ConnectionString="<%$ ConnectionStrings:TimeWSL2ConnectionString %>"
2                    SelectCommand="select fax, faxnotes from contact_fax where contact_fax.FK_fax_contact = @foreignKey"
3                    InsertCommand="Insert into contact_fax(fk_fax_contact, fax, faxnotes) values(@foreignKey, @fax, @faxnotes)"
4                    UpdateCommand="Update contact_fax set fax = @fax, faxNotes = @faxNotes where primkey = @primkey"
5                    DeleteCommand="Delete from contact_fax where primkey = @primkey">
6                        <SelectParameters>
7                             <asp:Parameter Name="foreignKey"    Type="Int64"    />
8                        </SelectParameters>
9                        <InsertParameters>
10                            <asp:Parameter  Name="foreignKey"   Type="Int64"    />
11                            <asp:Parameter Name="fax"          Type="String"   />
12                            <asp:Parameter Name="faxNotes"     Type="String"   />
13                       </InsertParameters>
14                       <UpdateParameters>
15                           <asp:Parameter Name="primkey"       Type="Int64"    />
16                           <asp:Parameter Name="fax"           Type="String"   />
17                           <asp:Parameter Name="faxNotes"      Type="String"   />
18                       </UpdateParameters>
19                       <DeleteParameters>
20                           <asp:Parameter Name="primkey"       Type="Int64"    />
21                       </DeleteParameters>
22                   </asp:SqlDataSource> 
23   
24    
25   
26   <asp:GridView ID="faxGV" runat="server" DataSourceID="faxDS" AutoGenerateColumns="false" OnRowCommand="faxGV_RowCommand1">           
27                       <Columns>                      
28                            <asp:TemplateField>
29                               <ItemTemplate>
30                                  <asp:Button Text="Edit"      CommandName="Edit"      CausesValidation="false"    runat="server" ID="btEdit"   PostBackUrl="~/details.aspx#vg"/>
31                                  <asp:Button Text="Delete"    CommandName="Delete"    CausesValidation="false"    runat="server" ID="btDelete" PostBackUrl="~/details.aspx#vg"/>
32                               </ItemTemplate>
33                               <EditItemTemplate>
34                                  <asp:Button Text="Update"    CommandName="Update"    CausesValidation="true"     runat="server" ID="btUpdate" PostBackUrl="~/details.aspx#vg"/>
35                                  <asp:Button Text="Cancel"    CommandName="Cancel"    CausesValidation="false"    runat="server" ID="btCancel" PostBackUrl="~/details.aspx#vg"/>
36                               </EditItemTemplate>
37                               <FooterTemplate>
38                                  <asp:Button Text="Insert"    CommandName="Insert"    CausesValidation="true"     runat="server" ID="btInsert" PostBackUrl="~/details.aspx#vg"/>
39                                  <asp:Button Text="Cancel"    CommandName="Cancel"    CausesValidation="false"    runat="server" ID="btCancel" PostBackUrl="~/details.aspx#vg"/>
40                               </FooterTemplate>
41                            </asp:TemplateField>
42                               
43                            <asp:TemplateField                 HeaderText="Fax">
44                               <ItemTemplate><asp:Label        ID="lblFax"    runat="server"  Text='<%# Eval("fax") %>'    /></ItemTemplate>
45                               <EditItemTemplate><asp:TextBox  ID="editFax"   runat="server"  Text='<%# Eval("fax") %>'    /></EditItemTemplate>
46                               <FooterTemplate><asp:TextBox    ID="faxInsert" runat="server"                               /></FooterTemplate>
47                            </asp:TemplateField>
48                       </Columns>
49                          
50                           <EmptyDataTemplate>
51                               <asp:Label      ID="lblInsFax"         Text="Fax"                runat="server" /><br />
52                               <asp:TextBox    ID="emptyFaxInsert"                            runat="server" /><br />
53                               <asp:Button     ID="btfaxEmptyInsert"           Text="Insert"    runat="server" CommandName="EmptyInsert"    UseSubmitBehavior="False"   PostBackUrl="~/details.aspx#vg"/>
54                               <asp:Button     ID="btEmptyCancel"      Text="Cancel"    runat="server" CommandName="Cancel"         CausesValidation="false"    PostBackUrl="~/details.aspx#vg"/>
55                           </EmptyDataTemplate>                             
56                   </asp:GridView>
57   
58    
59   
60   Public MustInherit Class contactInfo
61       Inherits System.Web.UI.UserControl
62   
63    
64
65   
66       Protected Sub faxGV_RowCommand1(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
67   
68           If e.CommandName = "EmptyInsert" Then
69               Try
70   
71                   Dim emptyFaxInsert As TextBox = CType(faxGV.Controls(0).Controls(0).FindControl("emptyFaxInsert"), TextBox)
72                   faxDS.InsertParameters("foreignKey").DefaultValue = foreignKey
73                   faxDS.InsertParameters("fax").DefaultValue = emptyFaxInsert.Text
74                   faxDS.Insert()
75   
76               Catch ex As Exception
77                   ' MsgBox(Err.Description)
78               End Try
79           End If
80   
81           If e.CommandName = "Insert" Then
82               Try
83                   Dim fRow As GridViewRow
84                   fRow = faxGV.FooterRow
85   
86                   Dim FaxInsert As TextBox = CType(fRow.FindControl("insertFax"), TextBox)
87                   faxDS.InsertParameters("foreignKey").DefaultValue = foreignKey
88                   faxDS.InsertParameters("fax").DefaultValue = FaxInsert.Text
89                   faxDS.Insert()
90   
91               Catch ex As Exception
92                   'MsgBox(Err.Description)
93               End Try
94           End If
95   
96           If e.CommandName = "Update" Then
97               Dim index As Integer = faxGV.EditIndex
98               Dim row As GridViewRow = faxGV.Rows(index)
99   
100              Dim editFax As TextBox = CType(row.FindControl("editFax"), TextBox)
101              Try
102                  faxDS.UpdateParameters("fax").DefaultValue = editFax.Text
103              Catch ex As Exception
104                  faxGV.EditIndex = -1
105                  faxGV.DataBind()
106  
107              End Try
108          End If
109  
110          If e.CommandName = "Cancel" Then
111              faxGV.EditIndex = -1
112              faxGV.DataBind()
113          End If
114          faxGV.EditIndex = -1
115          faxGV.DataBind()
116  
117      End Sub 
 
rmaiya
Asp.Net User
Re: asxc user control child controls are null7/6/2007 9:20:11 PM

0

 Looks correct to me. Check any exceptions are coming. remove msgbox and write Response.write or cosole.writeline()


Raghu
(MCSD.NET, MCAD.NET, MCDBA)
[Don't forget to click on Mark as answer on the post that helped you ]
jvw
Asp.Net User
Re: asxc user control child controls are null7/7/2007 4:47:39 PM

0

 Thank you for replying. No errors or exceptions of any kind seem to be occurring.  My debugging skills are quite nascent, however. I should be more clear about what is happening. When I click the insert button a row is created with the correct foreign key value but user entered data is lost.  Response.Write(emptyFaxInsert), for instance, writes nothing to the screen.

Maybe I should mention that, in the calling page, I have in the markup:

 

<asp:Repeater ID="Repeater1" runat="server" >
<ItemTemplate>
<tr><uc1:contactInfo2 ID="ContactInfo2" runat="server"
contactName='<%# DataBinder.Eval(Container.DataItem, "contact_name") %>' foreignKey=' <%# DataBinder.Eval(Container.DataItem, "primkey") %>'/> </tr></ItemTemplate> </asp:Repeater>
 
and in the Page_Load:

  
Dim IDs As IEnumerable = ContactDS.Select(DataSourceSelectArguments.Empty)
Repeater1.DataSource = IDs
Repeater1.DataBind()
 
3 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
asxc user control child controls are null - ASP.NET Forums Re: asxc user control child controls are null. 07-06-2007, 5:20 PM ... Re: asxc user control child controls are null. 07-07-2007, 12:47 PM ...
David Ebbo's blog : Turning an ascx user control into a ... You need to write logic to create child controls that you want to use, ..... NULL references exceptions for the child controls of the UserControl (.ascx) ...
ASP Net [Archive] - Page 212 Does anyone have an ActiveX control for browsing Directories · Unauthorized Access ... ImageUrl · Access Global.asxc of parent project from child project ...
.NET ASP Page 79 - Bytes Site Map Custom User Control is not rendered inside another user control in a .... Center text in a label · Accessing child controls of a nested repeater control ...
ASP.NET Development Oct 8, 2005 ... Here is my situation: I have a "mother" page add_customer.aspx and a"child" user control add_group.ascx. On the mother page is an "add ...
TheMSsForum.com >> Asp >> FreeTextBox in ASP.NET 2.0 - The ... I would just add the user control and then add the controls that I want on .... Here is the Code behind for the MenuTab.asxc which get implemented by my ...
TheMSsForum.com >> Asp >> Could not load type error - The ... Access Global.asxc of parent project from child project I have Solution with .... Here is what i have so far: In my User Control is a datagrid where you can ...
NETFrameworkASPNET .NET Framework Post aspnet Cannot find the id of the textbox on the user control ...... aspnet Access Global.asxc of parent project from child project ...
microsoft.public.dotnet.framework.aspnet Re: How to call VB.Net components from user control, Bon ...... Re: Access Global.asxc of parent project from child project, Scott Allen; is it possible to ...
Falafel Blog! - ASP.NET Go to the aspx (same applies for asxc files) file, and change the Page directive .... Normal, null). And to really take control of the scavenging mechanism, ...












step-by-step starter kit conversion to dnn

does dnn paging control force a tab/page reload?

how to find all the portals which have a particular module?

hide search function

what does menubreak really do?

error loading gallery

dnn 3.0x - feature request.

users.password query

arraylist to a textbox

failure sql execution resulted in following exceptions:

dnn3 and wiki

another dnn powered site

vps account with maximum asp - the default.aspx file

how do you modify what is required in registration?

multilanguage dotnetnukexxl problem

faster pickup...

minor possible bug in htmleditor provider, and one more feature request

dnn & blog websites

solpartmenu module used as vertical menu

who has parent portals on webshot4life? what's the secret?

url new design

show module by diferent alias

dnn 3.0.4 pages

automate child portal creation

display each root menu item with a different background color... how?

child portal creation running extremely slow

beta 2 conteiner html

questions about container

user specific home pages?

how to handle old links in google

cannot add new module definition

file transfered skins not loading

does dnn 3.0 and dnn 3.1 use the same db?

newbie:installation help

question on tokens in dnn 3.0

ftb problem

search engine module needed adapted to dnn

module sellers in general and magic gadget in perticular..

error converting data type nvarchar to datetime

acces to path "...dotnetnuke\verify" is denied.

new to dotnetnuke - how to create custom menu

portalalias changed but when i open from remote system i cannot view any other tabs but home

sql problem with 3.0.10 (aspnet roleprovider)

date site last updated

edit mode and preview

solpartmenu and css

looking for suggestions on string manipuation for module content

problem with module definitions

received error on subsequent edit to text/html module

fourm search stinks

 
Search This Site:

 
  Privacy | Contact Us
All Times Are GMT