You must Sign In to post a response.
  • Category: ASP.NET

    Data are shown for more time inside the gridview in asp.net

    my source

    <asp:GridView ID="GridView3" runat="server" BackColor="#CCCCCC"
    BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="6"
    CellSpacing="3" ForeColor="Black" AutoGenerateColumns="false"
    onselectedindexchanged="GridView3_SelectedIndexChanged"
    onrowdatabound="GridView3_RowDataBound" ShowFooter="True"
    onrowcommand="GridView3_RowCommand"
    onselectedindexchanging="GridView3_SelectedIndexChanging" DataKeyNames="billno" >

    <RowStyle BackColor="White" /><FooterStyle BackColor="White" Font-Bold="True" Font-Size="Larger" ForeColor="Black" /><PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" /><SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" /><HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
    <Columns>
    <asp:TemplateField>
    <ItemTemplate>
    <asp:CheckBox ID="chkSelect" runat="server" AutoPostBack="True" oncheckedchanged="chkSelect_CheckedChanged">
    </asp:CheckBox>
    </ItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="Sectionname" ControlStyle-Width="110px" ItemStyle-Width="120px" ControlStyle-Font-Bold="true">
    <ItemTemplate>
    <asp:Label ID="lsn" runat="server" Text="<%#bind('sectionname')%>"></asp:Label>
    </ItemTemplate>
    <ControlStyle Width="120px" />
    <ItemStyle Width="120px" />
    <HeaderStyle HorizontalAlign="Center" />
    <ItemStyle HorizontalAlign="Center" />
    </asp:TemplateField>
    <asp:TemplateField HeaderText="Partyname" ControlStyle-Width="120px" ItemStyle-Width="120px" ControlStyle-Font-Bold="true">
    <ItemTemplate>
    <asp:Label ID="LPM" runat="server" Text="<%#bind('partyname')%>"></asp:Label>
    </ItemTemplate>
    <ControlStyle Width="150px" />
    <ItemStyle Width="120px" />
    <HeaderStyle HorizontalAlign="Center" />
    <ItemStyle HorizontalAlign="Center" />
    </asp:TemplateField>

    <asp:TemplateField HeaderText="BillNo" ControlStyle-Width="90px" ItemStyle-Width="120px" ControlStyle-Font-Bold="true">
    <ItemTemplate>
    <asp:Label ID="LBN" runat="server" Text="<%#bind('billno') %>"></asp:Label>
    </ItemTemplate>
    <ControlStyle Width="150px" />
    <ItemStyle Width="120px" />
    <HeaderStyle HorizontalAlign="Center" />
    <ItemStyle HorizontalAlign="Center" />
    </asp:TemplateField>

    <asp:TemplateField HeaderText="Bill Date" ControlStyle-Width="120px" ItemStyle-Width="120px" ControlStyle-Font-Bold="true">
    <ItemTemplate>
    <asp:Label ID="LaDt" runat="server" Text="<%# bind('CharDate') %>"></asp:Label>
    </ItemTemplate>
    <ControlStyle Font-Bold="True" Width="150px" />
    <ItemStyle Width="120px" />
    <HeaderStyle HorizontalAlign="Center" />
    <ItemStyle HorizontalAlign="Center" />
    </asp:TemplateField>

    <asp:TemplateField HeaderText="Vat" ControlStyle-Width="120px" ItemStyle-Width="120px" ControlStyle-Font-Bold="true">
    <ItemTemplate>
    <asp:Label ID="Label90" runat="server" Text="<%# bind('vat') %>"></asp:Label>
    </ItemTemplate>
    <ControlStyle Font-Bold="True" Width="150px" />
    <ItemStyle Width="120px" />
    <HeaderStyle HorizontalAlign="Center" />
    <ItemStyle HorizontalAlign="Center" />
    </asp:TemplateField>


    <asp:TemplateField HeaderText="Discount" ControlStyle-Width="120px" ItemStyle-Width="120px" ControlStyle-Font-Bold="true">
    <ItemTemplate>
    <asp:Label ID="Label91" runat="server" Text="<%# bind('discount') %>"></asp:Label>
    </ItemTemplate>
    <ControlStyle Font-Bold="True" Width="150px" />
    <ItemStyle Width="120px" />
    <HeaderStyle HorizontalAlign="Center" />
    <ItemStyle HorizontalAlign="Center" />
    </asp:TemplateField>


    <asp:TemplateField HeaderText="Amount" ControlStyle-Width="120px" ItemStyle-Width="100px" ControlStyle-Font-Bold="true">
    <ItemTemplate>
    <asp:Label ID="lbt" runat="server" Text="<%#bind('billamount') %>"></asp:Label>
    </ItemTemplate>
    <ControlStyle Width="120px" />
    <ItemStyle Width="100px" />
    <HeaderStyle HorizontalAlign="Center" />
    <ItemStyle HorizontalAlign="Center" />
    <FooterTemplate>
    <asp:Label ID="bilamt" runat="server" />
    </FooterTemplate>
    </asp:TemplateField>


    <asp:TemplateField HeaderText="Pay" ControlStyle-Width="120px" ItemStyle-Width="100px" ControlStyle-Font-Bold="true">
    <ItemTemplate>
    <%-- <asp:Label ID="Label92" runat="server" Text="<%# Convert.ToDouble(lbt.Text)-Convert.ToDouble(TextBox18.Text) %>"></asp:Label>--%>
    <asp:TextBox ID="txtpay1" runat="server" AutoPostBack="True"
    ontextchanged="txtpay1_TextChanged" ></asp:TextBox>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:TextBox ID="TextBox20" runat="server" ></asp:TextBox>
    </EditItemTemplate>
    <ControlStyle Font-Bold="True" Width="120px" />
    <ItemStyle Width="100px" />
    <HeaderStyle HorizontalAlign="Center" />
    <ItemStyle HorizontalAlign="Center" />
    </asp:TemplateField>


    <asp:TemplateField HeaderText="Details" ControlStyle-Width="120px" ItemStyle-Width="100px" ControlStyle-Font-Bold="true">
    <ItemTemplate>
    <asp:DropDownList ID="txtdeatsparty" runat="server" AutoPostBack="True" onselectedindexchanged="txtdeatsparty_SelectedIndexChanged">
    <asp:ListItem Value="0">Select</asp:ListItem>
    <asp:ListItem>Atm</asp:ListItem>
    <asp:ListItem>Bank</asp:ListItem>
    <asp:ListItem>Cash</asp:ListItem>
    <asp:ListItem>Others</asp:ListItem>
    </asp:DropDownList>
    <%-- <asp:TextBox ID="txtdeatsparty" runat="server" ontextchanged="txtdeatsparty_TextChanged"></asp:TextBox>--%>
    </ItemTemplate>
    <ControlStyle Font-Bold="True" Width="120px" />
    <HeaderStyle HorizontalAlign="Center" />
    <ItemStyle HorizontalAlign="Center" />
    </asp:TemplateField>
    <asp:TemplateField HeaderText="Token No" ControlStyle-Width="120px" ItemStyle-Width="100px" ControlStyle-Font-Bold="true">
    <ItemTemplate>

    <asp:TextBox ID="txtToken" runat="server" ></asp:TextBox>
    </ItemTemplate>
    <ControlStyle Font-Bold="True" Width="120px" />
    <HeaderStyle HorizontalAlign="Center" />
    <ItemStyle HorizontalAlign="Center" />
    </asp:TemplateField>


    <asp:TemplateField HeaderText="Bankname" ControlStyle-Width="120px" ItemStyle-Width="100px" ControlStyle-Font-Bold="true">
    <ItemTemplate>

    <asp:DropDownList ID="txtbankname" runat="server" AutoPostBack="True">

    </asp:DropDownList>
    </ItemTemplate>
    <ControlStyle Font-Bold="True" Width="120px" />
    <HeaderStyle HorizontalAlign="Center" />
    <ItemStyle HorizontalAlign="Center" />
    </asp:TemplateField>


    <asp:TemplateField HeaderText="Return" ControlStyle-Width="120px" ItemStyle-Width="100px" ControlStyle-Font-Bold="true">
    <ItemTemplate>
    <asp:RadioButton ID="Return" runat="server" oncheckedchanged="Return_CheckedChanged" AutoPostBack="True" />
    </ItemTemplate>
    <ControlStyle Font-Bold="True" Width="120px" />
    <ItemStyle Width="100px" />
    <HeaderStyle HorizontalAlign="Center" />
    <ItemStyle HorizontalAlign="Center" />
    </asp:TemplateField>






    <asp:TemplateField HeaderText="SameAmount" ControlStyle-Width="120px" ItemStyle-Width="100px" ControlStyle-Font-Bold="true" Visible="false">
    <ItemTemplate>
    <asp:TextBox ID="foutput" runat="server" ></asp:TextBox>
    </ItemTemplate>
    <ControlStyle Font-Bold="True" Width="120px" />
    <ItemStyle Width="100px" />
    <HeaderStyle HorizontalAlign="Center" />
    <ItemStyle HorizontalAlign="Center" />
    </asp:TemplateField>



    <asp:TemplateField HeaderText="Balance" ControlStyle-Width="120px" ItemStyle-Width="100px" ControlStyle-Font-Bold="true" Visible="false">
    <ItemTemplate>
    <asp:TextBox ID="soutput" runat="server"></asp:TextBox>
    </ItemTemplate>
    <ControlStyle Font-Bold="True" Width="120px" />
    <ItemStyle Width="100px" />
    </asp:TemplateField>


    <asp:TemplateField Visible="false" >
    <ItemTemplate>
    <asp:TextBox ID="toutput" runat="server" ></asp:TextBox>
    </ItemTemplate>
    <HeaderStyle HorizontalAlign="Center" />
    <ItemStyle HorizontalAlign="Center" />
    </asp:TemplateField>



    <asp:TemplateField HeaderText="Remaining" Visible="false" >
    <ItemTemplate>
    <asp:TextBox ID="txtoutput" runat="server" ></asp:TextBox>
    </ItemTemplate>
    <HeaderStyle HorizontalAlign="Center" />
    <ItemStyle HorizontalAlign="Center" />
    </asp:TemplateField>

    <asp:TemplateField HeaderText="View" ControlStyle-Width="120px" ItemStyle-Width="100px" ControlStyle-Font-Bold="true">
    <ItemTemplate>
    <asp:LinkButton ID="LBView" runat="server" CommandName="View" CommandArgument="<%#bind('billno') %>" onclick="LBView_Click">View</asp:LinkButton>
    </ItemTemplate>
    <ControlStyle Width="120px" />
    <ItemStyle Width="100px" />
    <HeaderStyle HorizontalAlign="Center" />
    <ItemStyle HorizontalAlign="Center" />
    </asp:TemplateField>
    </Columns>

    </asp:GridView>



    my code

    protected void txtdeatsparty_SelectedIndexChanged(object sender, EventArgs e)
    {
    foreach (GridViewRow gvsr in this.GridView3.Rows)
    {
    if ((gvsr.FindControl("txtdeatsparty") as DropDownList).SelectedItem.ToString() == "Atm")
    {
    (gvsr.FindControl("txtToken")).Focus();
    break;
    }
    else if ((gvsr.FindControl("txtdeatsparty") as DropDownList).SelectedItem.ToString() == "Bank")
    {
    //if (!IsPostBack)
    //{

    string sq = "select ExpensesName from expenzsection where sectionname='" + (gvsr.FindControl("txtdeatsparty") as DropDownList).SelectedItem.Text.ToString() + "'";
    ds = mvl.GETDS(sq);
    /ListItem li1 = new ListItem();
    li1.Value = "--Select--";
    (gvsr.FindControl("txtbankname") as DropDownList).Items.Add(li1.ToString());
    (gvsr.FindControl("txtbankname") as DropDownList).DataSource = ds;
    (gvsr.FindControl("txtbankname") as DropDownList).DataValueField = "ExpensesName";
    (gvsr.FindControl("txtbankname") as DropDownList).DataBind();
    // }
    }
    else if ((gvsr.FindControl("txtdeatsparty") as DropDownList).SelectedItem.ToString() == "Cash")
    {

    }
    }
    }
  • #763724
    Hai Selvi,
    You have not described your issue in details. What do you mean by data is not shown for more time? Is it that the gridview data is not retaining?? If so then there could be some issue with the post back which is happening and flashing out the data.
    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #763733
    I have gone through the code and found no issue in code, what is the problem ? does it rebind your code in gridview or what ? pl. elaborate your problem so that we can help you better
    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #763752
    This is bad way to raise a question, please read the guidlines while asking question? if you post your full source code then what is the use of that? rather than post your source I suggest you to post the piece of code and explore your requirement clearly.
    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #763770
    Issue maybe in data side.

    1. Check the database data
    2. Check your data source and data binding part.

    By Nathan
    Direction is important than speed

  • #763853
    Whats the problem? If gridview looses its state after postback check if you enabled viewstate for the grid.
    If you are unable to do something properly for the first time, call it Version 1.0!

    Thanks & Regards,
    MONOJ BHUINA


Sign In to post your comments