Showing posts with label nested. Show all posts
Showing posts with label nested. Show all posts

Wednesday, March 28, 2012

LinkButton/DataGrid/HoverMenu Issue - Linkbutton not passing values?

Hello all,
I have a unique situation here, that I have been stumped on for 3 days now. I have a nested master/detail form as seen below, and within the 2nd grid I have an AJAX hovermenu, for some reason I am not able to collect the values of the form when the user wants to insert the values. I am able to capture the linkbutton event in the code behind but, when it gets to the assigning of the textbox value for entry into the DB it is comes up with a reference not set to the instance of an object. The first set of code is the asp.net page the second set is the code behind, any pointers on this would be extremely helpful, and I would owe you like lunch or something :) Thanks again for all of your help.

ASP.Net Code

1<asp:UpdatePanel ID="up0" runat="server" Visible="true">2 <ContentTemplate>3 <asp:GridView4 ID="GridView1"5 runat="server"6 Width="656px"7 CellPadding="4"8 DataSourceID="SqlDataSource1"9 ForeColor="#333333"10 OnRowDataBound="bindMarketControl"11 AutoGenerateColumns="False"12 GridLines="None"13 >14 <Columns>15 <asp:TemplateField>16 <ItemTemplate>17 <h2><%# Eval("MarketName")%></h2>18 <table width="100%">19 <tr>20 <td width="200px">Team Name</td>21 <td width="200px">Head Count</td>22 <td width="200px">Orders</td>23 <td width="200px">Revenue</td>24 </tr>25 </table>26 <asp:UpdatePanel ID="up1" runat="server">27 <ContentTemplate>28 <asp:GridView29 ID="TeamDetail"30 DataSourceID="GetTeamDetailFormView"31 AutoGenerateColumns="False"32 ShowHeader="False"33 GridLines="None"34 runat="server">35 <Columns>36 <asp:TemplateField>3738 <ItemTemplate>39 <asp:Panel CssClass="popupMenu" ID="PopupMenu" runat="server">40 <div style="border:1px outset white;padding:2px;">41 <div><asp:LinkButton42 ID="LinkButton1"43 runat="server"44 CommandName="Edit"45 Text="Edit"46 /></div>47 <div><asp:LinkButton48 ID="LinkButton2"49 runat="server"50 CommandName="Delete"51 Text="Delete" /></div>52 </div>53 </asp:Panel>54 <asp:Panel ID="Panel9" runat="server">55 <table width="100%">56 <tr>57 <td width="195px">58 <asp:Label59 Font-Bold="true"60 ID="Label0"61 runat="server"62 Text='<%# Eval("TeamName")%>' />63 </td>64 <td width="200px">65 <asp:Label66 ID="Label1"67 runat="server"68 Text='<%# Eval("HeadCount")%>' />69 </td>70 <td width="200px">71 <asp:Label72 ID="Label2"73 runat="server"74 Text='<%# Eval("Orders")%>' />75 </td>76 <td width="200px">77 <asp:Label78 ID="Label3"79 runat="server"80 Text='<%# Eval("Revenue")%>' />81 </td>82 </tr>83 </table>84 </asp:Panel>85 <cc1:HoverMenuExtender ID="hme2"86 HoverCssClass="popupHover"87 PopupControlID="PopupMenu"88 PopupPosition="Left"89 TargetControlID="Panel9"90 PopDelay="25"91 runat="server" />92 </ItemTemplate>93 <EditItemTemplate>94 <asp:Panel ID="Panel9" runat="server" Width="100%">95 <table width="100%">96 <tr>97 <td width="200px">98 <asp:TextBox99 ID="TextBox00"100 runat="server"101 Text='<%# Bind("TeamId")%>'102 Visible="false"103 EnableViewState="true"104 />105 <asp:TextBox106 ReadOnly="true"107 Font-Bold="true"108 ID="TextBox0"109 runat="server"110 Text='<%# Bind("TeamName")%>'111 EnableViewState="true" />112 </td>113 <td width="200px">114 <asp:TextBox115 ID="TextBox1"116 runat="server"117 Text='<%# Bind("HeadCount")%>'118 EnableViewState="true" />119 </td>120 <td width="200px">121 <asp:TextBox122 ID="TextBox2"123 runat="server"124 Text='<%# Bind("Orders")%>'125 EnableViewState="true"126 />127 </td>128 <td width="200px">129 <asp:TextBox130 ID="TextBox3"131 runat="server"132 Text='<%# Bind("Revenue")%>'133 EnableViewState="true" />134 </td>135 </tr>136 </table>137 </asp:Panel>138 <cc1:HoverMenuExtender139 ID="hme1"140 TargetControlID="Panel9"141 PopupControlID="PopupMenu"142 HoverCssClass="popupHover"143 PopupPosition="Right"144 runat="server">145 </cc1:HoverMenuExtender>146 <asp:Panel ID="PopupMenu" runat="server" CssClass="popupMenu">147 <div style="border:1px outset white">148 <div>149 <asp:LinkButton150 ID="lbtnInsertUpdate"151 runat="server"152 CausesValidation="True"153 CommandName="Insert"154 Text="Insert"155 OnClick="lbtnInsertUpdate_Click"156 />157 </div>158 <div>159 <asp:LinkButton160 ID="LinkButton2"161 runat="server"162 CausesValidation="False"163 CommandName="Cancel"164 Text="Cancel" /></div>165 </div>166 </asp:Panel>167 </EditItemTemplate>168 </asp:TemplateField>169 </Columns>170 </asp:GridView>171 </ContentTemplate>172 </asp:UpdatePanel>173 <asp:SqlDataSource174 ID="GetTeamDetailFormView"175 runat="server"176 ConnectionString="<%$ ConnectionStrings:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX%>"177 SelectCommand="sp_GetTeamDetails"178 SelectCommandType="StoredProcedure"179 InsertCommand="sp_InsertDataInfo"180 InsertCommandType="StoredProcedure">181 <SelectParameters>182 <asp:Parameter Name="MarketID" />183 <asp:ControlParameter184 ControlID="ddlVPInfo"185 DefaultValue=""186 Name="vpid"187 PropertyName="SelectedValue"188 Type="Int32" />189 </SelectParameters>190 <InsertParameters>191 <asp:Parameter Name="TeamID" />192 <asp:Parameter Name="HeadCount" />193 <asp:Parameter Name="Orders" />194 <asp:Parameter Name="Revenue" />195 <asp:ControlParameter196 ControlID="tbEntryDat"197 Name="DataDate"198 PropertyName="Text"199 Type="String" />200 </InsertParameters>201 </asp:SqlDataSource>202 <hr />203 </ItemTemplate>204 </asp:TemplateField>205 </Columns>206 </asp:GridView>207208 <asp:SqlDataSource209 ID="SqlDataSource1"210 runat="server"211 ConnectionString="<%$ ConnectionStrings:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX%>"212 SelectCommand="sp_GetMarketCats"213 SelectCommandType="StoredProcedure">214 <SelectParameters>215 <asp:ControlParameter216 ControlID="ddlVPInfo"217 DefaultValue=""218 Name="vpid"219 PropertyName="SelectedValue"220 Type="Int32" />221 </SelectParameters>222 </asp:SqlDataSource>223224 </ContentTemplate>225 <Triggers>226 <asp:AsyncPostBackTrigger227 ControlID="btnDisplayEntry"228 EventName="Click" />229 </Triggers>230 </asp:UpdatePanel>

The Code Behind

1Protected Sub lbtnInsertUpdate_Click(ByVal senderAs Object,ByVal eAs EventArgs)2Dim TeamInfoDBConnAs New SqlConnection(ConfigurationManager.ConnectionStrings("XXXXXXXXXXXXXXXXX").ConnectionString)3Dim sqlStringAs String ="sp_InsertDataInfo"4Dim sqlCmdAs New SqlCommand(sqlString, TeamInfoDBConn)5 sqlCmd.CommandType = CommandType.StoredProcedure67'Dim NewText As String =8 'Dim val1 As TextBox = CType(e.Item.FindControl("TextBox3"), TextBox)9 'MsgBox(val1.Text)101112 sqlCmd.Parameters.AddWithValue("@dotnet.itags.org.TeamID", TextBox00.Text)13 sqlCmd.Parameters.AddWithValue("@dotnet.itags.org.HeadCount", TextBox1.Text)14 sqlCmd.Parameters.AddWithValue("@dotnet.itags.org.Orders", TextBox2.Text)15 sqlCmd.Parameters.AddWithValue("@dotnet.itags.org.Revenue", TextBox3.Text)16 sqlCmd.Parameters.AddWithValue("@dotnet.itags.org.DataDate", tbEntryDate.Text)1718 TeamInfoDBConn.Open()19 sqlCmd.ExecuteNonQuery()20 TeamInfoDBConn.Close()21 sqlCmd =Nothing22 End Sub

Bump...Still looking for anyone that might have some idea about this one?? thank-you!

Saturday, March 24, 2012

Literal nested in UpdatePanel error: "Object reference not set to an instance of an object

I am trying to set the content of a literal which is nested inside an UpdatePanel. But when I try to reference the Literal control, I get this message: "Object reference not set to an instance of an object." This despite the fact that the name shows in Intellisense. Actually, not entirely true. It sometimes isn't showing in Intellisense, for reasons I can't fathom. But I'm not getting a compilation error, so I assume it does recognise the name, but for some reason the object is null. Here's the code:

 <asp:UpdatePanel runat="server" ID="UpdatePanel1" EnableViewState ="true" Visible="true" RenderMode="Block" UpdateMode="Conditional"> <asp:ContentTemplate> <div style="width:350px; height:400px" class="newscontent"> <asp:Literal runat="server" ID="litContent"></asp:Literal> </div> </asp:ContentTemplate> </asp:UpdatePanel>

C#:

protected void Refresh(Object Sender, RepeaterCommandEventArgs e) {if (e.CommandName=="GetContent") {int id = Convert.ToInt32((e.CommandArgument)); ObjectModel.News item =new ObjectModel.News(id); litContent.Text = item.Content; litContent.Text += DisplayDocuments(id); UpdatePanel1.Update(); } }
The Refresh function is triggered by the user clicking on a LinkButton in a repeater, but this is irrelevant to the problem, since I get the same error message if I put a simple line of code in the page load function to set the text property on the the literal.

just yesterday got same problem with accordion control and textbox

spend about 3 hours here how it goes :UpdatePanel1 onpage load or on page init try this code

///////////////////////////////////////////////////////////////////////////

Literal litContent=newLiteral();

litContent= UpdatePanel1.FindControl ("litContent") asLiteral;

////////////////////////////////////////////////////


Sol90046:

just yesterday got same problem with accordion control and textbox

spend about 3 hours here how it goes :UpdatePanel1 onpage load or on page init try this code

///////////////////////////////////////////////////////////////////////////

Literal litContent=newLiteral();

litContent= UpdatePanel1.FindControl ("litContent") asLiteral;

////////////////////////////////////////////////////

Thank you! This worked as far as eliminating my error message went. But even though the code now appears to be doing what it is told, i.e., I can step through it in debug mode and the text property of the Literal is being set to the correct content, the update panel is not displaying the results. It also appears to be doing a full page refresh rather than a partial one. I do have a scriptmanager on the page with EnablePartialRendering set to true.