동적 컨트롤이있는 모달 팝업이 있습니다. 버튼 클릭에 새 텍스트 상자를 추가해야합니다.모달 팝업 버튼을 두 번 클릭하지 못했습니다.
JQuery와 -
<script type="text/javascript">
$(document).ready(function(){
if($('#hdnclick').val()==1){
$('#modelPopup').dialog({
autoopen:false,
title: "Add New Server",
width:650,
height:450,
modal:true,
buttons:{
Close:function(){
$(this).dialog('close');
}
}
});
$('#btnadd').click(function(){
alert('okay');
});
}
});
</script>
영문 코드 : -
<asp:GridView ID="grdservices" runat="server" AutoGenerateColumns="false" ShowFooter="true">
<Columns>
<asp:BoundField DataField="S.No" HeaderText="s.no" />
<asp:TemplateField HeaderText="service name">
<ItemTemplate>
<asp:TextBox ID="txtservicename" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="description">
<ItemTemplate>
<asp:TextBox ID="txtDescription" runat="server"></asp:TextBox>
</ItemTemplate>
<FooterStyle HorizontalAlign="right" />
<FooterTemplate>
<asp:Button ID="btnadd" runat="server" Text="add new service" OnClick="btnadd_Click" OnRowCommand="ButtonClicked" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
/asp:GridView>
내 문제는이 "btnAddNewServic_Click"버튼을 클릭이 첫 번째 클릭하지만 "btnAddNewServic_Click"기능에 해고 해고하지 두 번째 클릭에서도 아무 것도 두 번째 클릭에서 해고되지 않습니다. 새 행을 추가
: 사람이 하나 .. 나에게이 문제를 복구하는
출력을 도와 드릴까요 -
protected void grdServices_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "ButtonClicked")
{
hdnclick.Value = "1";
AddNewRowToGrid();
}
}
private void AddNewRowToGrid()
{
int rowindex = 0;
if (ViewState["CurrentTable"] != null)
{
DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"];
DataRow drCurrentRow = null;
if (dtCurrentTable.Rows.Count > 0)
{
for (int i = 1; i <= dtCurrentTable.Rows.Count; i++)
{
TextBox Box1 = (TextBox)grdservices.Rows[rowindex].Cells[1].FindControl("txtservicename");
TextBox Box2 = (TextBox)grdservices.Rows[rowindex].Cells[2].FindControl("txtDescription");
drCurrentRow = dtCurrentTable.NewRow();
drCurrentRow["S.No"] = i + 1;
dtCurrentTable.Rows[i - 1]["Column1"] = Box1.Text;
dtCurrentTable.Rows[i - 1]["Column2"] = Box2.Text;
rowindex++;
}
dtCurrentTable.Rows.Add(drCurrentRow);
ViewState["CurrentTable"] = dtCurrentTable;
grdservices.DataSource = dtCurrentTable;
grdservices.DataBind();
}
}
}
은 새 단추 또는 행을 추가 할 코드를 보여줍니다. – cracker
새 행을 추가하는 코드를 추가했습니다. –
코드의 단추를 코드에 추가하지 않고 코드를 추가하면 작동합니다. – cracker