i have created page has 1 gridview , 1 form. gridview working properly. form has textbox user name or email address , submit button. form working properly.
below form, need create table or grid store each user name , email added. how can create table in such way 1 line added each btnsenduser_onclick event? table must not delete rows inserted previously. table shows 1 row (the recent).
my aspx
<asp:gridview id="gridview" runat="server" autogeneratecolumns="false" gridlines="none" cssclass="table table-bordered table-striped"> <columns> <asp:boundfield datafield="accessgroup" headertext="access group" /> </asp:templatefield> <asp:templatefield headertext="business justification"> <itemtemplate> <asp:textbox id="txtjustbuss" runat="server" height="17px" width="150px"></asp:textbox> </itemtemplate> </asp:templatefield> </columns> </asp:gridview> <asp:label id="lbluseradd" runat="server" font-bold="true" text="add user - (email or user name)"></asp:label> <br /> <asp:textbox id="txtuseradd" runat="server" height="17px" width="150px"></asp:textbox> <asp:label id="lblerror" runat="server" class="control-label" for="inputerror" visible="false">input error</asp:label> <asp:button id="btnadduser" class="btn" runat="server" font-bold="true" text="add user" onclick="btnsenduser_onclick" /> <br /> <br /> <table id="tblusers" class="table table-bordered table-striped" runat="server" visible="false"> <tbody> <tr> <td> <asp:label id="lbluser" runat="server" visible="false"></asp:label> </td> <td> <asp:label id="lblemail" runat="server" visible="false"></asp:label> </td> </tr> </tbody> </table> my .cs
protected void btnsenduser_onclick(object sender, eventargs e) { string logininfo = txtuseradd.text; principalcontext insprincipalcontext = new principalcontext(contexttype.domain, "x.com", "amsuser", "xx"); userprincipal insuserprincipal = userprincipal.findbyidentity(insprincipalcontext, logininfo); if (insuserprincipal == null) { lblerror.visible = true; } else { tblusers.visible = true; lbluser.visible = true; lblemail.visible = true; lbluser.text = insuserprincipal.givenname + " " + insuserprincipal.surname; lblemail.text = insuserprincipal.emailaddress; } }
you should use component designed deal collection of values - example grid.
if heavy, can update labels this:
lbluser.text = lbluser.text + insuserprincipal.givenname + " " + insuserprincipal.surname + "<br />"; lblemail.text = lblemail.text + insuserprincipal.emailaddress + "<br />";
Comments
Post a Comment