As written in the title I have problems assigning values to the textbox inside a panel. The problem is that a button from gvAsseti doesn't show the pnlAsset (which has textboxes in it) and doesn't load the values into the textboxes.
What is strange is that code executes fine and while using debugger I was able to see that correct values are sent to the textboxes, but for some reason they aren't displayed (all I get are empty textboxes).
Here is the codefront (sorry for the length, you can skip the middle part, it has only textboxes):
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<uc:Firma ID="ucFirma" runat="server"></uc:Firma>
<asp:GridView ID="gvKontakti" runat="server" OnRowCommand="gvKontakti_RowCommand"
DataKeyNames="idKontakt">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnShowAssets" runat="server" CommandArgument='<%# Eval("idKontakt") %>'
CommandName="ShowAssets" Text="Prikaži assete" />
<asp:Button ID="btnAddAsset" runat="server" CommandArgument='<%# Eval("idKontakt") %>'
CommandName="AddAsset" Text="Dodaj asset" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="idKontakt" HeaderText="ID" Visible="false" />
<asp:BoundField DataField="Naziv" HeaderText="Naziv" />
</Columns>
</asp:GridView>
<asp:Panel ID="pnlAsset" runat="server">
<table>
<tr>
<td>
Naziv:
</td>
<td colspan="3">
<asp:TextBox ID="txtNaziv" runat="server" Width="430px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Kod 1:
</td>
<td>
<asp:TextBox ID="txtKod1" runat="server"></asp:TextBox>
</td>
<td>
Kod 2:
</td>
<td>
<asp:TextBox ID="txtKod2" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Datum isteka garancije:
</td>
<td>
<asp:TextBox ID="txtGarancija" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Lokacija:
</td>
<td colspan="3">
<asp:TextBox ID="txtLokacija" runat="server" TextMode="MultiLine" Width="455px" Height="200px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Opis:
</td>
<td colspan="3">
<asp:TextBox ID="txtOpis" runat="server" TextMode="MultiLine" Width="455px" Height="200px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Aktivna imovina:
</td>
<td>
<asp:CheckBox ID="chkAktivna" runat="server" />
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnSave" runat="server" Text="Spremi" OnClick="btnSave_Click" />
</td>
</tr>
</table>
</asp:Panel>
<asp:UpdatePanel ID="upAsseti" runat="server">
<ContentTemplate>
<asp:GridView ID="gvAsseti" runat="server" onrowcommand="gvAsseti_RowCommand">
<Columns>
<asp:TemplateFiel开发者_运维百科d>
<ItemTemplate>
<asp:Button ID="btnShowAsset" runat="server" CommandArgument='<%# Eval("idAsset") %>'
CommandName="ShowAsset" Text="Prikaži asset" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
And also the codebehind:
protected void gvAsseti_RowCommand(object sender, GridViewCommandEventArgs e)
{
int idFirma = Convert.ToInt32(Request.QueryString["idt"]);
int idAsset = Convert.ToInt32(e.CommandArgument);
TicketingSystemEntities db = new TicketingSystemEntities();
if (e.CommandName=="ShowAsset")
{
var asset = (from a in db.Assets
where a.idAsset == idAsset
select a).SingleOrDefault();
pnlAsset.Visible = true;
txtGarancija.Text = asset.DatumGarancije.ToString();
txtKod1.Text = asset.Kod1;
txtKod2.Text = asset.Kod2;
txtLokacija.Text = asset.Lokacija;
txtNaziv.Text = asset.Naziv;
txtOpis.Text = asset.Opis;
if (asset.Aktivan == true)
{
chkAktivna.Checked = true;
}
else
{
chkAktivna.Checked = false;
}
}
}
}
Any help would be appreciated.
Put the panel inside the updatepanel contenttemplate. As gvAsseti's inside an updatepanel, therefore it'll be refreshing the contents of the updatepanel on postback.
精彩评论