1 .Aspx page code:
use this javascript for confirm dialog box in header tab
<script language="javascript" type="text/javascript">
confirmB(status) // Active/Inactive{
{if(status == "Active")if(window.confirm("Do you really want to Inativate this Admin User?"))return true;else
}return false;else{if(window.confirm("Do you really want to Activate this Admin User?"))return true;else
}
}return false;</script><asp:GridView ID="gvAdmin" runat="server" SkinID="gridviewSkin" DataKeyNames="UserID,isActive" OnRowCommand="gvAdmin_RowCommand" Height="140px" OnPageIndexChanging="gvAdmin_PageIndexChanging" AutoGenerateColumns="False"><FooterStyle BackColor="#6D2C90" ForeColor="White" Height="20px"/><RowStyle BackColor="#E9E6F0" ForeColor="Black" Height="20px" /><AlternatingRowStyle BackColor="#DFD9EB" ForeColor="Black" /><PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" /><SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" /><HeaderStyle BackColor="#6D2C90" Font-Bold="True" ForeColor="White" /><Columns><asp:BoundField HeaderText="Full Name" HeaderStyle-Width="25%" HeaderStyle-Height="25px" DataField="fullname"ItemStyle-HorizontalAlign="Left"><HeaderStyle Width="25%"></HeaderStyle><ItemStyle Wrap="true" /></asp:BoundField><asp:BoundField HeaderText="EMail Address" HeaderStyle-Width="25%" DataField="EMAIL"ItemStyle-HorizontalAlign="Left"><HeaderStyle Width="25%"></HeaderStyle><ItemStyle Wrap="true" /></asp:BoundField><asp:BoundField HeaderText="User Name" HeaderStyle-Width="20%" DataField="LOGINID" ItemStyle-HorizontalAlign="Left"><HeaderStyle Width="20%"></HeaderStyle><ItemStyle Wrap="true" /></asp:BoundField><asp:BoundField HeaderText="Phone/MOBILE1#" HeaderStyle-Width="10%" DataField="MOBILE"ItemStyle-HorizontalAlign="Center"><HeaderStyle Width="10%"></HeaderStyle><ItemStyle Wrap="true" /></asp:BoundField>
<asp:TemplateField HeaderText="Status"><ItemTemplate>
<asp:LinkButton ID="lnkStatus" runat="server" Text='<%#Eval("isActive") %>' CommandArgument='<%#Eval("UserID") +"|"+ Eval("isActive")+"|"+ Eval("CID") %>' CommandName="Activate" OnClientClick='<%#Eval("isActive", "return confirmB(\"{0}\")")%>'></asp:LinkButton>
</ItemTemplate> </asp:TemplateField>
<asp:TemplateField HeaderText="Allow Upload Document"><ItemTemplate>
<asp:LinkButton ID="lnkuploadStatus" runat="server" Text='<%#Eval("UploadDocument") %>' CommandArgument='<%#Eval("UserID") +"|"+ Eval("UploadDocument")+"|"+ Eval("CID") %>' CommandName="Upload" OnClientClick='<%#Eval("UploadDocument", "return confirmupload(\"{0}\")")%>'></asp:LinkButton>
</ItemTemplate> </asp:TemplateField>
</Columns>
2. SQL stored procedure for filling gridview
CREATE
PROCEDURE fillgriedview AS BEGIN SELECT UserID, LOGINID, FIRSTNAME + ' ' + LASTNAME AS fullname, EMAIL, PHONE1 +'/'+ MOBILE1 as MOBILE, CASE ISNULL(ISACTIVE,0) WHEN 0 THEN 'Inactive' ELSE 'Active' END AS isActive,CID,CASE ISNULL(UploadDocument,0) WHEN 0 THEN 'Inactive' ELSE 'Active' END
AS UploadDocument FROM dbo.Users WHERE ROLE IN('Cadmin') ORDER BY FIRSTNAME, LASTNAME DESC END
3. code behind page
// write this on page load
if (!IsPostBack)
BindGrid()
private void BindGrid()
{
write code for filling griedview as per ur need
}
protected void gvAdmin_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("Activate"))
{
// Write code here which will work on clicking gridview cell hyperlink and u can get value of link like this
(e.CommandArgument.ToString().Split('|')[1].ToString().ToUpper() == "ACTIVE") ? 0 : 1;}
Convert.ToInt32(e.CommandArgument.ToString().Split('|')[0].ToString());
}
}
Hope this help you.
use this javascript for confirm dialog box in header tab
<script language="javascript" type="text/javascript">
confirmB(status) // Active/Inactive{
{if(status == "Active")if(window.confirm("Do you really want to Inativate this Admin User?"))return true;else
}return false;else{if(window.confirm("Do you really want to Activate this Admin User?"))return true;else
}
}return false;</script><asp:GridView ID="gvAdmin" runat="server" SkinID="gridviewSkin" DataKeyNames="UserID,isActive" OnRowCommand="gvAdmin_RowCommand" Height="140px" OnPageIndexChanging="gvAdmin_PageIndexChanging" AutoGenerateColumns="False"><FooterStyle BackColor="#6D2C90" ForeColor="White" Height="20px"/><RowStyle BackColor="#E9E6F0" ForeColor="Black" Height="20px" /><AlternatingRowStyle BackColor="#DFD9EB" ForeColor="Black" /><PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" /><SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" /><HeaderStyle BackColor="#6D2C90" Font-Bold="True" ForeColor="White" /><Columns><asp:BoundField HeaderText="Full Name" HeaderStyle-Width="25%" HeaderStyle-Height="25px" DataField="fullname"ItemStyle-HorizontalAlign="Left"><HeaderStyle Width="25%"></HeaderStyle><ItemStyle Wrap="true" /></asp:BoundField><asp:BoundField HeaderText="EMail Address" HeaderStyle-Width="25%" DataField="EMAIL"ItemStyle-HorizontalAlign="Left"><HeaderStyle Width="25%"></HeaderStyle><ItemStyle Wrap="true" /></asp:BoundField><asp:BoundField HeaderText="User Name" HeaderStyle-Width="20%" DataField="LOGINID" ItemStyle-HorizontalAlign="Left"><HeaderStyle Width="20%"></HeaderStyle><ItemStyle Wrap="true" /></asp:BoundField><asp:BoundField HeaderText="Phone/MOBILE1#" HeaderStyle-Width="10%" DataField="MOBILE"ItemStyle-HorizontalAlign="Center"><HeaderStyle Width="10%"></HeaderStyle><ItemStyle Wrap="true" /></asp:BoundField>
<asp:TemplateField HeaderText="Status"><ItemTemplate>
<asp:LinkButton ID="lnkStatus" runat="server" Text='<%#Eval("isActive") %>' CommandArgument='<%#Eval("UserID") +"|"+ Eval("isActive")+"|"+ Eval("CID") %>' CommandName="Activate" OnClientClick='<%#Eval("isActive", "return confirmB(\"{0}\")")%>'></asp:LinkButton>
</ItemTemplate> </asp:TemplateField>
<asp:TemplateField HeaderText="Allow Upload Document"><ItemTemplate>
<asp:LinkButton ID="lnkuploadStatus" runat="server" Text='<%#Eval("UploadDocument") %>' CommandArgument='<%#Eval("UserID") +"|"+ Eval("UploadDocument")+"|"+ Eval("CID") %>' CommandName="Upload" OnClientClick='<%#Eval("UploadDocument", "return confirmupload(\"{0}\")")%>'></asp:LinkButton>
</ItemTemplate> </asp:TemplateField>
</Columns>
2. SQL stored procedure for filling gridview
CREATE
PROCEDURE fillgriedview AS BEGIN SELECT UserID, LOGINID, FIRSTNAME + ' ' + LASTNAME AS fullname, EMAIL, PHONE1 +'/'+ MOBILE1 as MOBILE, CASE ISNULL(ISACTIVE,0) WHEN 0 THEN 'Inactive' ELSE 'Active' END AS isActive,CID,CASE ISNULL(UploadDocument,0) WHEN 0 THEN 'Inactive' ELSE 'Active' END
AS UploadDocument FROM dbo.Users WHERE ROLE IN('Cadmin') ORDER BY FIRSTNAME, LASTNAME DESC END
3. code behind page
// write this on page load
if (!IsPostBack)
BindGrid()
private void BindGrid()
{
write code for filling griedview as per ur need
}
protected void gvAdmin_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("Activate"))
{
// Write code here which will work on clicking gridview cell hyperlink and u can get value of link like this
(e.CommandArgument.ToString().Split('|')[1].ToString().ToUpper() == "ACTIVE") ? 0 : 1;}
Convert.ToInt32(e.CommandArgument.ToString().Split('|')[0].ToString());
}
}
Hope this help you.
No comments:
Post a Comment