Jul 05, 2011, 2:29 PM
[CLOSED] How to check checkbox based on database column value
HI,
Can you please help me how to check checkbox in GridPanel depending on the database value.
in query ,status column getting bit value( 1 or 0). based this column value i want check the checkbox.
where I need to write a code for this am not getting.
here is my code
-------------------------------------
Can you please help me how to check checkbox in GridPanel depending on the database value.
in query ,status column getting bit value( 1 or 0). based this column value i want check the checkbox.
where I need to write a code for this am not getting.
here is my code
-------------------------------------
.aspx
---------------
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="EmployeeSecurity.aspx.vb"
Inherits="EmployeeSecurity" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script>
function adminRenderer(value)
{
if(value==="")
return '';
else
{
value=(value==true)?1:0;
return adminCmb.getStore().data.items[value].data.text;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<ext:ResourceManager ID="ResourceManager1" runat="server" Theme="Slate">
</ext:ResourceManager>
<asp:SqlDataSource ID="securityDataSource" runat="server" SelectCommand="select gsEmployeesID,firstName, lastName, admin from dbo.gsEmployees"
UpdateCommand="update tblMagFrequencyIssueSet set admin=@admin where gsEmployeesID=@gsEmployeesID "
ConnectionString="<%$ConnectionStrings:WizardConnstr%>">
<UpdateParameters>
<asp:Parameter DbType="String" Name="admin" />
</UpdateParameters>
</asp:SqlDataSource>
<ext:Store ID="securityStore" runat="server" DataSourceID="securityDataSource">
<Reader>
<ext:JsonReader IDProperty="gsEmployeesID">
<Fields>
<ext:RecordField Name="gsEmployeesID">
</ext:RecordField>
<ext:RecordField Name="firstName">
</ext:RecordField>
<ext:RecordField Name="lastName">
</ext:RecordField>
<ext:RecordField Name="admin">
</ext:RecordField>
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
<ext:GridPanel ID="GridPanel1" runat="server" StoreID="securityStore" AutoHeight="true"
TrackMouseOver="true" StripeRows="true" Title="Employee Security">
<LoadMask ShowMask="true" />
<ColumnModel ID="ColModel1" runat="server">
<Columns>
<ext:Column DataIndex="firstName" Header="First Name">
</ext:Column>
<ext:Column DataIndex="lastName" Header="Last Name">
</ext:Column>
<ext:Column DataIndex="admin" Header="Administrator">
<Editor>
<ext:ComboBox runat="server" ID="adminCmb">
<Items>
<ext:ListItem Text="No" Value="0" />
<ext:ListItem Text="Yes" Value="1" />
</Items>
</ext:ComboBox>
</Editor>
<Renderer Fn="adminRenderer" />
</ext:Column>
<ext:CommandColumn>
<Commands>
<ext:GridCommand Text="Prodcuts" StandOut="true" CommandName="Prodcuts">
<ToolTip Text="Click to view the issues" />
</ext:GridCommand>
<ext:GridCommand Text="Display" StandOut="true" CommandName="Display">
<ToolTip Text="Click to view the issues" />
</ext:GridCommand>
<ext:GridCommand Text="Notifications" StandOut="true" CommandName="Notifications">
<ToolTip Text="Click to view the issues" />
</ext:GridCommand>
</Commands>
</ext:CommandColumn>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel runat="server" SingleSelect="false" ID="RowSelectionModel1">
</ext:RowSelectionModel>
</SelectionModel>
<DirectEvents>
<Command OnEvent="Command">
<ExtraParams>
<ext:Parameter Name="cmdName" Value="command" Mode="Raw">
</ext:Parameter>
<ext:Parameter Name="empId" Value="record.id" Mode="Raw">
</ext:Parameter>
</ExtraParams>
</Command>
</DirectEvents>
</ext:GridPanel>
<ext:Window runat="server" ID="productsWin" Hidden="true" Title="Products" Modal="true"
Width="400" Height="400">
<Content>
<ext:Panel runat="server" Width="400" Height="400">
<Content>
<asp:SqlDataSource ID="productDatasource" runat="server" SelectCommand="select gsPublicationID, PubName,case when gsEmployeesID IS NULL then 0 else 1 end status from gsPublications gp left outer join tblEmployee2Pub tep on gp.gsPublicationID=tep.PubID and tep.gsEmployeesID = @gsEmployeesID "
ConnectionString="<%$ConnectionStrings:WizardConnstr%>">
<SelectParameters>
<asp:Parameter DbType="String" Name="gsEmployeesID" />
</SelectParameters>
</asp:SqlDataSource>
<ext:Store ID="productStore" runat="server" DataSourceID="productDatasource">
<Reader>
<ext:JsonReader IDProperty="gsPublicationID">
<Fields>
<ext:RecordField Name="gsPublicationID">
</ext:RecordField>
<ext:RecordField Name="PubName">
</ext:RecordField>
<ext:RecordField Name="status">
</ext:RecordField>
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
<ext:GridPanel ID="productGP" runat="server" StoreID="productStore" Width="380" Height="350">
<ColumnModel runat="server">
<Columns>
<ext:Column DataIndex="PubName" Header="Product Name">
</ext:Column>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:CheckboxSelectionModel runat="server" ID="SelectionModel1" ColumnPosition="1">
</ext:CheckboxSelectionModel>
</SelectionModel>
</ext:GridPanel>
</Content>
</ext:Panel>
</Content>
</ext:Window>
</div>
</form>
</body>
</html>
-----------------
.aspx.cs
------------------------
Imports Ext.Net
Imports System.Data
Partial Class EmployeeSecurity
Inherits System.Web.UI.Page
Public strEmpId As String = String.Empty
Protected Sub Command(ByVal sender As Object, ByVal e As DirectEventArgs)
Session("empId") = e.ExtraParams(1).Value
Select Case e.ExtraParams(0).Value
Case "Options"
Case "Record"
Case "Prodcuts"
productDatasource.SelectParameters("gsEmployeesID").DefaultValue = Convert.ToString(e.ExtraParams(1).Value)
productStore.DataBind()
productsWin.Show()
Case "Display"
Case "Notifications"
End Select
End Sub
End Class
Last edited by Daniil; Jul 11, 2011 at 9:36 AM.
Reason: Please use [CODE] tags, [CLOSED]