Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have gridview contain membership providers Roles.
with Link Button For edit and Link button for deleting .

i succeeded in populate the modal and bind the grid and all of that , but , how can i bind the txtRoleName in the modal with the role name of the row ? without any post back if its could happen or with post back if it's not .

here is my code

ASP.NET
<asp:GridView ID="grdRoles"
            CssClass="table table-bordered responsive"
            runat="server"
            GridLines="None"
            CellSpacing="-1" 
            AutoGenerateColumns="False"
            OnPageIndexChanging="grdRoles_PageIndexChanging"
            OnRowDataBound="grdRoles_RowDataBound"
            ShowFooter="True" ShowHeaderWhenEmpty="True" EmptyDataText="Empty !">
            <Columns>

                <asp:TemplateField HeaderText="#">
                    <ItemTemplate>
                        <asp:Label ID="lblRank" runat="server" Text='<%# Container.DataItem %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Roles">
                    <ItemTemplate>
                        <asp:Label ID="lblRoleName" runat="server" Text='<%# Container.DataItem %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Action">
                    <ItemTemplate>
                    <asp:LinkButton  ID="btnEdit" data-toggle="modal"  href="#EditModal" runat="server" CssClass="btn  icon-edit" />
                    <asp:LinkButton  ID="btnRemove" runat="server" CssClass="btn btn-danger remove"  Text="icon-remove">" />

                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>

        </asp:GridView>



and here is the modal


ASP.NET
<div id="EditModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="Edit"
         aria-hidden="true">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3 id="helpModalLabel"> Edit Role</h3>
        </div>
        <div class="modal-body">

             <div class="control-group">
            <div class="controls">
                <div class="input-prepend">
                    <span class="add-on">Role Name</span>
                    <asp:TextBox ID="txtRoleName" Text='<%# Bind("RoleId") %>' runat="server"></asp:TextBox>
                </div>
            </div>

             <div class="form-actions">
                 <asp:Button ID="btnSave" type="submit" class="btn btn-primary" runat="server" Text="Save" />
            </div>
                 </div>
        </div>
        <div class="modal-footer">

            <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
        </div>
    </div>


image of the grid
Grid[]
Modal : Modal[]

thanks in advance
Posted
Updated 31-Jul-13 7:55am
v3

1 solution

instead of this

ASP.NET
<asp:linkbutton id="btnEdit" data-toggle="modal" href="#EditModal" runat="server" cssclass="btn  icon-edit" xmlns:asp="#unknown" /> 


use this

ASP.NET
<asp:linkbutton id="btnEdit" data-toggle="modal" data-target="#EditModal" runat="server" cssclass="btn  icon-edit" xmlns:asp="#unknown" /> 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900