>

Thursday, June 03, 2010

To change the background color or to change the inner text of a item in dropdown

Breach of TrustExile on Main StreetAvatar (Two-Disc Blu-ray/DVD Combo) [Blu-ray]

To change the background color or to change the inner text of a item in dropdown



// Loop around the dropdown
for (row = 0; row < ddlUserName.Items.Count; row++)
{
// To color a particular user name
if (ddlUserName.Items[row].Value == this.USERID.ToString())
ddlUserName.Items[row].Attributes.Add("style",
"background-color:" + "#663333;color:#ffffff;");
}

Wednesday, June 02, 2010

Gridview headertemplate with checkbox and client side ( javascript) handling of select all / unselect all

Hitachi C10FCE2 10-Inch Compound Miter Saw9.5x10mm AAA Quality Japanese Akoya saltwater cultured pearl necklace 51" triple strand Rope
Gridview headertemplate with checkbox and client side handling of select all / unselect all using javascript.
courtesy from
http://dotnetslackers.com/Community/blogs/kaushalparik/archive/2008/07/16/checkbox-in-headertemplate-to-select-all-checkboxes-inside-a-gridview-using-javascript.aspx

Idea and code from this site, I enhached and made small corrections this for my application, according to my requirement

Thanks to http://dotnetslackers.com/ for all the code.




        <div>

        <input type="hidden" id="hdnCheckBoxValue" />

            <table>

                <tr>

                    <td style="width: 100px;">

                        <asp:GridView ID="gvVendorBulletin">

                            <Columns>

                                <asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle"

                                    HeaderText="" ItemStyle-BorderWidth="0">

                                    <ItemTemplate>

                                        <asp:CheckBox ID="chkItem" runat="server" onclick="VendorItemSelected(this)" />

                                    </ItemTemplate>

                                    <HeaderTemplate>

                                        <asp:CheckBox ID="chkHdrItem" runat="server" onclick="VendorSelectAll(this)" />

                                    </HeaderTemplate>

                                </asp:TemplateField>

                            </Columns>

                        </asp:GridView>

                    </td>

                </tr>

            </table>

        </div>



<script language="javascript" type="text/javascript">

function callFileDownload(a,b)

{

  function callCheckAllVendor(CheckBox) {



            TotalChkBx = parseInt('<%= this.gvVendorBulletin.Rows.Count %>');

            var TargetBaseControl = document.getElementById('<%= this.gvVendorBulletin.ClientID %>');

            var TargetChildControl = "chkItem";

            var Inputs = TargetBaseControl.getElementsByTagName("input");

            var flag = true;

            document.getElementById("hdnCheckBoxValue").value = true;

            for (var iCount = 0; iCount < Inputs.length; ++iCount) {

                if (Inputs[iCount].type == 'checkbox' && Inputs[iCount].id.indexOf(TargetChildControl, 0) >= 0) {

                    if (!Inputs[iCount].checked) {                      

                        flag = false;

                        document.getElementById("hdnCheckBoxValue").value = false;

                        return;

                    }

                }

            }           

        }

        function VendorSelectAll(CheckBox) {

            TotalChkBx = parseInt('<%= this.gvVendorBulletin.Rows.Count %>');

            var TargetBaseControl = document.getElementById('<%= this.gvVendorBulletin.ClientID %>');

            var TargetChildControl = "chkItem";

            var Inputs = TargetBaseControl.getElementsByTagName("input");

            for (var iCount = 0; iCount < Inputs.length; ++iCount) {

                if (Inputs[iCount].type == 'checkbox' && Inputs[iCount].id.indexOf(TargetChildControl, 0) >= 0)

                    Inputs[iCount].checked = CheckBox.checked;

            }

        }

        function VendorItemSelected(CheckBox) {



            TotalChkBx = parseInt('<%= this.gvVendorBulletin.Rows.Count %>');

            var TargetBaseControl = document.getElementById('<%= this.gvVendorBulletin.ClientID %>');

            var TargetChildControl = "chkHdrItem";

            var Inputs = TargetBaseControl.getElementsByTagName("input");                       

            if (!CheckBox.checked) {

                for (var iCount = 0; iCount < Inputs.length; ++iCount) {

                    if (Inputs[iCount].type == 'checkbox' && Inputs[iCount].id.indexOf(TargetChildControl, 0) >= 0)

                        Inputs[iCount].checked = CheckBox.checked;

                }

            }

            else {

                callCheckAllVendor(CheckBox);               

                var flags;

                if (document.getElementById("hdnCheckBoxValue").value == "true") {

                    flags = true;

                }

                else {

                    flags = false;

                }

                for (var iCount = 0; iCount < Inputs.length; ++iCount) {

                    if (Inputs[iCount].type == 'checkbox' && Inputs[iCount].id.indexOf(TargetChildControl, 0) >= 0)

                        Inputs[iCount].checked = flags;

                }

            }

        }

}

</script>

Dynamically add CommandField of type Image to a gridview or any container.

Kindle Wireless Reading Device (6" Display, Global Wireless, Latest Generation)


Dynamically add CommandField of type Image to a grid or any container.

if (!IsPostBack)
{
if (Session["USERTYPE"].ToString() == "S")
{
CommandField ImageCommand = new CommandField();
ImageCommand.ButtonType = ButtonType.Image;
ImageCommand.DeleteImageUrl = "~/images/delete.gif";
ImageCommand.ShowCancelButton = false;
ImageCommand.ShowDeleteButton = true;
GridView1.Columns.Add(ImageCommand);
}
}

Then do the normal

protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{

}



to delete or change as per your requirements.

Wednesday, July 08, 2009

A New Operating System from GOOGLE: IS that a Downfall to WINDOWS?

Google is about to introduce a new OS in the middle of 2010, is that meant to compete the giant Windows?, Is that to be a David to Windows?

Read further:

Google Blog

Economic Times