Pages

Monday, November 14, 2011

Telerik Multiple RadGrid

Here below code is telerik multiple radgrid. You can't copy paste this code but need to change the code as your requirment.



<telerik:RadGrid ID="gridRoles" runat="server" Skin="WebBlue" AutoGenerateColumns="False"
                    PageSize="5" AllowSorting="True" AllowPaging="True" GridLines="None" AllowAutomaticDeletes="True"
                    AllowAutomaticInserts="True" AllowAutomaticUpdates="True" OnDetailTableDataBind="gridRoles_DetailTableDataBind"
                    OnPageIndexChanged="gridRoles_PageIndexChanged" 
                    OnItemCommand="gridRoles_ItemCommand" onitemdatabound="gridRoles_ItemDataBound">
                    <HeaderContextMenu EnableImageSprites="True">
                    </HeaderContextMenu>
                    <PagerStyle Mode="NumericPages"></PagerStyle>
                    <MasterTableView Width="100%" HierarchyDefaultExpanded="false" DataKeyNames="Roleid">
                        <DetailTables>
                            <telerik:GridTableView Width="40%" runat="server" Name="Modules" HorizontalAlign="Center">
                                <ParentTableRelation>
                                    <telerik:GridRelationFields DetailKeyField="Roleid" MasterKeyField="Roleid" />
                                </ParentTableRelation>
                                <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
                                <Columns>
                                    <telerik:GridBoundColumn DataField="Roleid" UniqueName="Roleid" Visible="false">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn SortExpression="ModuleName" HeaderText="Module Names" DataField="ModuleName"
                                        UniqueName="ModuleName">
                                    </telerik:GridBoundColumn>
                                </Columns>
                            </telerik:GridTableView>
                        </DetailTables>
                        <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
                        <ExpandCollapseColumn Visible="True">
                        </ExpandCollapseColumn>
                        <Columns>
                            <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Edit" UniqueName="EditCommandColumn">
                                <ItemStyle HorizontalAlign="Center" />
                            </telerik:GridButtonColumn>
                            <telerik:GridBoundColumn DataField="Roleid" UniqueName="Roleid" Visible="false">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn SortExpression="Rolename" HeaderText="Role name" DataField="Rolename"
                                UniqueName="Rolename">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn SortExpression="Status" HeaderText="Status" DataField="Status"
                                UniqueName="Status">
                            </telerik:GridBoundColumn>
                            <telerik:GridButtonColumn ConfirmText="Delete this Role?" ConfirmTitle="Delete" ButtonType="ImageButton"
                                CommandName="Delete" UniqueName="DeleteColumn" ConfirmDialogType="RadWindow"
                                ConfirmDialogHeight="100" ConfirmDialogWidth="300">
                                <ItemStyle HorizontalAlign="Center" />
                            </telerik:GridButtonColumn>
                        </Columns>
                        <SortExpressions>
                            <telerik:GridSortExpression FieldName="Rolename" />
                        </SortExpressions>
                        <EditFormSettings>
                            <EditColumn UniqueName="EditCommandColumn1">
                            </EditColumn>
                        </EditFormSettings>
                    </MasterTableView>
                </telerik:RadGrid>

Query for add two nvarchar time columns

Query this in sql query editor:
select from,convert(nvarchar(10),(convert(datetime,Colname1)+convert(datetime,Colname2)),108) as to from  table


Result will be:

Encrypt Appsettings in web.Config


Add these below two lines in pageload event:
ProtectSection("appSettings","DataProtectionConfigurationProvider");
UnProtectSection("appSettings");


Add these methods

private void ProtectSection(string p, string p_2)
    {
        Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);


        ConfigurationSection section = config.GetSection(p);


        if (section != null && !section.SectionInformation.IsProtected)
        {
            section.SectionInformation.ProtectSection(p_2);
            config.Save();
        }
    }


    private void UnProtectSection(string sectionName)
    {
        Configuration config =
            WebConfigurationManager.
                OpenWebConfiguration(Request.ApplicationPath);


        ConfigurationSection section =
                  config.GetSection(sectionName);


        if (section != null &&
              section.SectionInformation.IsProtected)
        {
            section.SectionInformation.UnprotectSection();
            config.Save();
        }
    }


After executing this just go to web.config file and check the app settings tag.

Monday, July 4, 2011

.NET and C# interview questions:Show how do we view an assembly in .NET?


When coming to understand the internals, nothing can beat ILDASM. ILDASM converts the whole ‘exe’ or ‘dll’ in to IL code. To run ILDASM you have to go to ‘C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin’. Note that we had v1.1 you have to probably change it depending on the type of framework version you have.
If you run IDASM.EXE from the path you will be popped with the IDASM exe
program as shown in figure. Click on file and browse to the respective
directory for the DLL whose assembly you want to view. After you select the
DLL you will be popped with a tree view details of the DLL as shown in
figure ILDASM. On double clicking on manifest, you will be able to view
details of assembly, internal IL code etc as shown in the figure.

Note: - The version number are in the manifest itself which is defined with
the DLL or EXE thus making deployment much easier as compared to COM where
the information was stored in registry. Note the version information in Figure
Manifest view.
You can expand the tree for detail information regarding the DLL like methods, properties, functions etc.


And once you open the Manifest you will be able to see the inner details as shown in the following picture: -


Following is the video which shows that how the questions are asked C#
and .NET interviews.