"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Showing posts with label GridView. Show all posts
Showing posts with label GridView. Show all posts

Friday, February 1, 2013

addition operation in Grid inside the text box using javascript

Having addition operation on gridview in JavaScript.


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

Tuesday, January 29, 2013

Changing image within Gridview programatically

Simple RowdataBound event isit? an alternate if it reduce memory load and time. wht abt that :)
Yup by jquery :)

Monday, October 22, 2012

Print a div or grid in javascript

 Hi *.*,
 

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Print Gridview Data in asp.net</title>
<script type="text/javascript">
function PrintGridData() {
var prtGrid = document.getElementById('<%=gvUserInfo.ClientID %>');
prtGrid.border = 0;
var prtwin = window.open('', 'PrintGridViewData', 'left=100,top=100,width=1000,height=1000,tollbar=0,scrollbars=1,status=0,resizable=1');
prtwin.document.write(prtGrid.outerHTML);
prtwin.document.close();
prtwin.focus();
prtwin.print();
prtwin.close();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<b>Print Gridview Data</b><br /><br />
<asp:GridView ID="gvUserInfo" runat="server" >
<HeaderStyle BackColor="#df5015" Font-Bold="true" ForeColor="White"/>
</asp:GridView>
<input type="button" id="btnPrint" value="Print" onclick="PrintGridData()" />
</div>
</form>
</body>
</html>




If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)

Saturday, November 12, 2011

Hyperlink with more than one parameter Or Error: Server tag not well Formed with Hyperlink

Hi *.*,
In my first day of .net i found this error the with the help of my senior i resolved it.Then i didn't know why it come so.2day my junior faced same issue i gone through and got why it come :).its all because when binding hyperlink with data not at just data, you have to give entire NavigateUrl the Server control. and also (single quote) and (Double quote) have to be in correct way too...

Tuesday, November 8, 2011

Thursday, October 27, 2011

Setting column width for gridview

Hi *.*,
It sounds simple but hard part when implements.Visual studio is giving us a option to set width of header and item template .But it not work !!!! :(
After an war of 1 hour with the help of our designer we achieve it :) .
Done by adding table-layout:fixed  to gridview style and define HeaderStyle-Width="xx PX".
Game is over !!!

If u had any trouble just ask, Happy to help u :) 
Stay Tune... 
Have a nice day... 'N happy Coding :)

Monday, September 12, 2011

Nested grid and findControl over child grid

Hi *.*,
Nested grid and findControl over child grid
Over here i have two gridview (GridView1,GridView2) and on 2nd grid  a linkbutton, onclick event i need to extract particular row data. that my need here its go.
 On HTML


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound">
            <Columns>
                <asp:TemplateField HeaderText="Project">
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("PkID") %>'></asp:Label>
                        <asp:Label ID="Label3" runat="server" Text='<%# Bind("StrName") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Sub Task">
                    <ItemTemplate>
                        <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" OnRowCommand="GridView2_RowCommand">
                            <Columns>
                                <asp:TemplateField HeaderText="Task Name">
                                    <ItemTemplate>
                                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("name") %>'></asp:Label>
                                        <asp:Label ID="Label4" runat="server" Text='<%# Bind("pk") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Task Status">
                                    <ItemTemplate>
                                        <asp:DropDownList ID="DropDownList1" runat="server">
                                            <asp:ListItem>Open</asp:ListItem>
                                            <asp:ListItem>Close</asp:ListItem>
                                            <asp:ListItem>Finish</asp:ListItem>
                                        </asp:DropDownList>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Select" CommandArgument="<%#((GridViewRow) Container).RowIndex %>">Update</asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                            <HeaderStyle BackColor="#CCCCFF" />
                        </asp:GridView>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <HeaderStyle BackColor="Maroon" ForeColor="#FFCC00" />
        </asp:GridView>
    </div>
    </form>
</body>
</html>

 
protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            GridView1.DataSource = d("SELECT PkID, StrName, DateTimeStamp FROM T2");
            GridView1.DataBind();
        }
    }

    public SqlDataReader d(string _Query)
    {
        SqlCommand cmd = new SqlCommand(_Query, con());
         return cmd.ExecuteReader();

    }

    public SqlConnection  con()
    {
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ConnectionDemoString"].ToString());
        con.Open();
        return con;
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        try
        {
            if (e.Row.RowType == DataControlRowType.DataRow)// Bind nested grid view with parent grid view
            {
                string _name = ((Label)e.Row.FindControl("Label3")).Text;
                GridView griedview2 = (GridView)e.Row.FindControl("GridView2");
                griedview2.DataSource = d("SELECT     pk, name, DrpDwn FROM         TBNAME where DrpDwn='" + _name + "'");
                griedview2.DataBind();
            }
        }
        catch (Exception)
        {
           
            throw;
        }
    }
    protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        GridView GridView2 = (GridView)sender;  //find nested grid view
        GridViewRow chrow = (GridViewRow)GridView2.Parent.Parent; // parent grid's row for find any control from parent grid view
        if (e.CommandName == "Select")
        {
            int index = Convert.ToInt32(e.CommandArgument); //use command argument for identify row with nested grid view

            int pid = Convert.ToInt32(((Label)GridView2.Rows[index].FindControl("Label4")).Text); // id from labe4 of nested grid view
            DropDownList childrop = ((DropDownList)GridView2.Rows[index].FindControl("DropDownList1")); // get dropdownlist box of nested grid view
            string status = childrop.SelectedItem.Text;
        }

Hope u guys got it....If any trouble message me. :)
Stay Tune...
Have a nice day... 'N happy Coding :)