网格视图值发送到文本框 [英] Grid view value send to textbox
问题描述
嗨
i有一个模态弹出窗口,其中包含一个网格视图。我想要网格视图选择行值发送到文本框值然后模态弹出隐藏
modal.aspx
Hi
i have a modal popup which contain a grid view .I want grid view select row value send to text box value and then modal pop up hide
modal.aspx
<td class="TDLeftLabel"> Name </td>
<td class="TDRightInput">
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
</td>
<td class="TDLeftLabel" width="32%">
Designation
</td>
<td class="TDRightInput" width="32%">
<asp:TextBox ID="txtDesignation" runat="server"></asp:TextBox>
</td>
</tr>
<input id="btnSpecial" type="button" value="Special" önclick="$('#divSimplePopup').showModal(); return false;"
runat="server" />
<div id="divSimplePopup" class="popup" style="display: none; width: 650px;">
<div class="headerpop">
<span id="lblPopupHeader" class="msg">Special Modal</span> <a id="btnClosePopup"
class="close" önclick="$('#divSimplePopup').hideModal(); return false;"></a>
</div>
<div class="body" style="height: 270px; width: 628px; overflow: auto;">
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<table width="100%" cellpadding="0" cellspacing="0" style="border-collapse: collapse">
<tr>
<td>
<table class="TableWorkArea" border="1px" cellpadding="3" style="border-collapse: collapse">
<tr>
<td class="TDLeftLabel" width="18%" colspan="4">
<asp:GridView ID="grdModal" runat="server" Width="600px" AutoGenerateColumns="False"
AllowPaging="True" EnableViewState="False" DataKeyNames="HolyDaySetupID" OnSelectedIndexChanged="grdModal_SelectedChanged" OnRowCommand="grdModal_RowCommand" >
<Columns>
<asp:TemplateField>
<HeaderTemplate>
ID
</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton CommandName="cmdBind" PostBackUrl='<%# Eval("HolyDaySetupID" )%>' Text='<%# Eval("HolyDaySetupID" )%>'
ID="lnk" OnClick="lnk_Click" runat="server" />
</ItemTemplate>
<ItemStyle Width="20px" />
</asp:TemplateField>
<asp:BoundField DataField="FromDate" HeaderText="Date" DataFormatString="{0:dd MMM, yyyy}"
ItemStyle-Width="90px">
<ItemStyle Width="90px" />
</asp:BoundField>
<asp:BoundField DataField="Remarks" HeaderText="Remarks" ItemStyle-Width="20px">
<ItemStyle Width="20px" />
</asp:BoundField>
</Columns>
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="#DCDCDC" />
<selectedrowstyle backcolor="LightCyan" forecolor="DarkBlue" font-bold="true"/>
</asp:GridView>
</td>
</tr>
</table>
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="grdModal" EventName="RowCommand" />
<asp:AsyncPostBackTrigger ControlID="grdModal" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</div>
<div class="footerpop">
<input class="button_popup" id="btnCancel" önclick="$('#divSimplePopup').hideModal(); return false;"
type="submit" value="OK" />
</div>
</div>
modal.aspx.cs
modal.aspx.cs
void grdModal_RowCommand(object sender, GridViewCommandEventArgs e)
{
txtName.Text = grdModal.SelectedRow.Cells[0].Text;
}
void LoadGrid()
{
var repository = new HolyDaySetupRepository();
var holydaysetup = new HolyDaySetupDto();
repository.LoadHolidaySetupGrid(grdModal);
}
protected void grdModal_SelectedChanged(object sender, EventArgs e)
{
txtName.Text = grdModal.SelectedRow.Cells[0].Text;
}
protected void lnk_Click(object sender, EventArgs e)
{
int ID = Convert.ToInt32(((LinkButton)sender).CommandArgument);
txtName.Text = grdModal.SelectedRow.Cells[0].Text;
}
this is error
CS1061: ’’ASP.hr_attendance_modal_aspx’’ does not contain a definition for ’’grdModal_RowCommand’’ and no extension method ’’grdModal_RowCommand’’ accepting a first argument of type ’’ASP.hr_attendance_modal_aspx’’ could be found (are you missing a using directive or an assembly reference?)
pls help me to solve this problem
this is error
CS1061: ''ASP.hr_attendance_modal_aspx'' does not contain a definition for ''grdModal_RowCommand'' and no extension method ''grdModal_RowCommand'' accepting a first argument of type ''ASP.hr_attendance_modal_aspx'' could be found (are you missing a using directive or an assembly reference?)
pls help me to solve this problem
推荐答案
('#divSimplePopup').showModal(); return false;\"
runat=\"server\" />
<div id=\"divSimplePopup\" class=\"popup\" style=\"display: none; width: 650px;\">
<div class=\"headerpop\">
<span id=\"lblPopupHeader\" class=\"msg\">Special Modal</span> <a id=\"btnClosePopup\"
class=\"close\" önclick=\"
('#divSimplePopup').showModal(); return false;" runat="server" /> <div id="divSimplePopup" class="popup" style="display: none; width: 650px;"> <div class="headerpop"> <span id="lblPopupHeader" class="msg">Special Modal</span> <a id="btnClosePopup" class="close" önclick="
('#divSimplePopup').hideModal(); return false;\"></a>
</div>
<div class=\"body\" style=\"height: 270px; width: 628px; overflow: auto;\">
<asp:UpdatePanel ID=\"UpdatePanel2\" runat=\"server\">
<ContentTemplate>
<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\">
<tr>
<td>
<table class=\"TableWorkArea\" border=\"1px\" cellpadding=\"3\" style=\"border-collapse: collapse\">
<tr>
<td class=\"TDLeftLabel\" width=\"18%\" colspan=\"4\">
<asp:GridView ID=\"grdModal\" runat=\"server\" Width=\"< span class=\"code-keyword\">600px\" AutoGenerateColumns=\"False\"
AllowPaging=\"True\" EnableViewState=\"False\" DataKeyNames=\"HolyDaySetupID\" OnSelectedIndexChanged=\"grdModal_SelectedChanged\" OnRowCommand=\"grdModal_RowCommand\" >
<Columns>
<asp:TemplateField>
<HeaderTemplate>
ID
</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton CommandName=\"cmdBind\" PostBackUrl='<%# Eval(\"HolyDaySetupID\" )%>' Text='<%# Eval(\"HolyDaySetupID\" )%>'
ID=\"lnk\" OnClick=\"lnk_Click\" runat=\"server\" />
</ItemTemplate>
<ItemStyle Width=\"20px\" />
</asp:TemplateField>
<asp:BoundField DataField=\"FromDate\" HeaderText=\"Date\" DataFormatString=\"{0:dd MMM, yyyy}\"
< span class =code-attribute> < span class =code-attribute>ItemStyle-Width=\"90px\">
<ItemStyle Width=\"90px\" />
</asp:BoundField>
<asp:BoundField DataField=\"Remarks\" HeaderText=\"Remarks\" ItemStyle-Width=\"20px\">
<ItemStyle Width=\"20px\" />
</asp:BoundField>
</Columns>
<PagerStyle BackColor=\"#999999 \" ForeColor=\"Black\" HorizontalAlign=\"Center\" />
<SelectedRowStyle BackColor=\"#008A8C\" Font-Bold=\"True\" ForeColor=\"White\" />
<HeaderStyle BackColor=\"#000084\" Font-Bold=\"True\" ForeColor=\"White\" />
<AlternatingRowStyle BackColor=\"#DCDCDC\" />
<selectedrowstyle backcolor=\"LightCyan\" forecolor=\"DarkBlue\" font-bold=\"true\"/>
</asp:GridView>
</td>
</tr>
</table>
</td>
</tr< span class=\"code-keyword\">>
</table>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID=\"grdModal\" EventName=\"RowCommand\" />
<asp:AsyncPostBackTrigger ControlID=\"grdModal\" EventName=\"SelectedIndexChanged\" />
</Triggers>
</asp:UpdatePanel>
</div>
<div class=\"footerpop\">
<input class=\"button_popup\" id=\"btnCancel\" önclick=\"
('#divSimplePopup').hideModal(); return false;"></a> </div> <div class="body" style="height: 270px; width: 628px; overflow: auto;"> <asp:UpdatePanel ID="UpdatePanel2" runat="server"> <ContentTemplate> <table width="100%" cellpadding="0" cellspacing="0" style="border-collapse: collapse"> <tr> <td> <table class="TableWorkArea" border="1px" cellpadding="3" style="border-collapse: collapse"> <tr> <td class="TDLeftLabel" width="18%" colspan="4"> <asp:GridView ID="grdModal" runat="server" Width="600px" AutoGenerateColumns="False" AllowPaging="True" EnableViewState="False" DataKeyNames="HolyDaySetupID" OnSelectedIndexChanged="grdModal_SelectedChanged" OnRowCommand="grdModal_RowCommand" > <Columns> <asp:TemplateField> <HeaderTemplate> ID </HeaderTemplate> <ItemTemplate> <asp:LinkButton CommandName="cmdBind" PostBackUrl='<%# Eval("HolyDaySetupID" )%>' Text='<%# Eval("HolyDaySetupID" )%>' ID="lnk" OnClick="lnk_Click" runat="server" /> </ItemTemplate> <ItemStyle Width="20px" /> </asp:TemplateField> <asp:BoundField DataField="FromDate" HeaderText="Date" DataFormatString="{0:dd MMM, yyyy}" ItemStyle-Width="90px"> <ItemStyle Width="90px" /> </asp:BoundField> <asp:BoundField DataField="Remarks" HeaderText="Remarks" ItemStyle-Width="20px"> <ItemStyle Width="20px" /> </asp:BoundField> </Columns> <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" /> <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" /> <AlternatingRowStyle BackColor="#DCDCDC" /> <selectedrowstyle backcolor="LightCyan" forecolor="DarkBlue" font-bold="true"/> </asp:GridView> </td> </tr> </table> </td> </tr> </table> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="grdModal" EventName="RowCommand" /> <asp:AsyncPostBackTrigger ControlID="grdModal" EventName="SelectedIndexChanged" /> </Triggers> </asp:UpdatePanel> </div> <div class="footerpop"> <input class="button_popup" id="btnCancel" önclick="
('#divSimplePopup').hideModal( ); return false;\"
type=\"submit\" value=\"OK\" />
</div>
</div>
('#divSimplePopup').hideModal(); return false;" type="submit" value="OK" /> </div> </div>
modal.aspx.cs
modal.aspx.cs
void grdModal_RowCommand(object sender, GridViewCommandEventArgs e)
{
txtName.Text = grdModal.SelectedRow.Cells[0].Text;
}
void LoadGrid()
{
var repository = new HolyDaySetupRepository();
var holydaysetup = new HolyDaySetupDto();
repository.LoadHolidaySetupGrid(grdModal);
}
protected void grdModal_SelectedChanged(object sender, EventArgs e)
{
txtName.Text = grdModal.SelectedRow.Cells[0].Text;
}
protected void lnk_Click(object sender, EventArgs e)
{
int ID = Convert.ToInt32(((LinkButton)sender).CommandArgument);
txtName.Text = grdModal.SelectedRow.Cells[0].Text;
}
this is error
CS1061: ’’ASP.hr_attendance_modal_aspx’’ does not contain a definition for ’’grdModal_RowCommand’’ and no extension method ’’grdModal_RowCommand’’ accepting a first argument of type ’’ASP.hr_attendance_modal_aspx’’ could be found (are you missing a using directive or an assembly reference?)
pls help me to solve this problem
this is error
CS1061: ''ASP.hr_attendance_modal_aspx'' does not contain a definition for ''grdModal_RowCommand'' and no extension method ''grdModal_RowCommand'' accepting a first argument of type ''ASP.hr_attendance_modal_aspx'' could be found (are you missing a using directive or an assembly reference?)
pls help me to solve this problem
这篇关于网格视图值发送到文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!