hey all
can someone answer me why one works and the other doesnt?
this one works
<asp:UpdatePanel ID="up1" runat="server">
<ContentTemplate>
<asp:LinkButton ID="lb1" runat="server" Text="+Add"></asp:LinkButton>
<asp:Panel runat="server" ID="addPanel" style="display:none">
add this: <asp:TextBox runat="server" ID="toAdd" Text="orig text"></asp:TextBox><br />
<asp:Button ID="addButt" runat="server" OnClick="addNote" Text="addButt" />
</asp:Panel>
</p
<AjaxToolkit:ModalPopupExtender ID="mpe1" runat="server"
TargetControlID="lb1"
PopupControlID="addPanel"
>
</AjaxToolkit:ModalPopupExtender>
</contenttemplate>
</asp:UpdatePanel
but this one does not work
<asp:GridView ID="gv" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lb2" runat="server" Text="+Add2"></asp:LinkButton>
<asp:Panel runat="server" ID="addPanel2" style="display:none">
add this: <asp:TextBox runat="server" ID="toAdd2" Text="orig text2"></asp:TextBox><br />
<asp:Button ID="addButt2" runat="server" OnClick="addNote" Text="addButt2" />
</asp:Panel>
</p
<AjaxToolkit:ModalPopupExtender ID="mpe2" runat="server"
TargetControlID="lb2"
PopupControlID="addPanel2"
>
</AjaxToolkit:ModalPopupExtender>
</ItemTemplate></asp:TemplateField>
</Columns></asp:GridView
and this does not work either
<asp:UpdatePanel runat="server" ID="up2">
<ContentTemplate>
<asp:GridView ID="gv2" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lb2" runat="server" Text="+Add2"></asp:LinkButton>
<asp:Panel runat="server" ID="addPanel2" style="display:none">
add this: <asp:TextBox runat="server" ID="toAdd2" Text="orig text2"></asp:TextBox><br />
<asp:Button ID="addButt2" runat="server" OnClick="addButt_Click" Text="addButt2" />
</asp:Panel>
</p
<AjaxToolkit:ModalPopupExtender ID="mpe2" runat="server"
TargetControlID="lb2"
PopupControlID="addPanel2"
BackgroundCssClass="modalBackground"
DropShadow="true"
>
</AjaxToolkit:ModalPopupExtender>
</ItemTemplate></asp:TemplateField>
</Columns></asp:GridView>
</ContentTemplate>
</asp:updatepanel>
what happens in the the ones that dont work (ie, with the gridview)
is that the debugger throws an error that the addButt procedure cant find the textbox text
pls help!
i would love the third example to work
toy
welll did you give us the code for that procedure?
If textbox is in gridview you must use: ((TextBox)NameofGridView.FindControl("NameofTexBox")).Text - this is to call the text contained in the text box ...
thanks for the quick response
here is the code- behind
protected void addButt_Click(object sender, EventArgs e)
{
int uid = 1;
string newNote = "note";
newNote = toAdd.Text;
// suggested above but doesnt work
// newNote = ((TextBox)GridView2.FindControl("toAdd")).Text;
if (!string.IsNullOrEmpty(newNote))
{
// setup connx
SqlConnection conn = new SqlConnection(cs);
conn.Open();
string sql = "insertnote";
SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
SqlCommand cmd = new SqlCommand(sql);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@.note", newNote));
cmd.Connection = conn;
int numRowsAffected = cmd.ExecuteNonQuery();
conn.Close();
}
}
but correct me if im wrong - i dont think the code-behind really matters
because it works without the gridview
once i put the MPE in the gridview - thats when it breaks
also i tried your suggestion and that didnt work either
i think its cuase the textbox is in the MPE panel and not the gridview
No comments:
Post a Comment