Click here to Skip to main content
16,016,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I am making a webform in which a client will search his Data, for that i use Ajax tabpanel and for showing result i am using Gridview, i also has make the dataSource in gridview and bind the data. But problem is that its not showing Gridview in ajax tab panel. Kindly tell me whats the problem behind that i am sending my Code also




ASP.NET
<cc1:TabContainer ID="TabContainer2"  runat="server"  AutoPostBack="true">
<cc1:TabPanel ID="TabPanel3"  runat="server">
    <HeaderTemplate>
    Search By IEMI
    <HeaderTemplate>
                        
    <ContentTemplate>
    <table>
    <tr>
        <td>IEMI / SER</td>
	<td><asp:TextBox ID="txtSearchIEMI" runat="server"></asp:TextBox></td>
    </tr>
    <tr>
        <td>Brand</td>
	<td><asp:TextBox ID="txtSearchBrand" runat="server"></asp:TextBox></td>
	</tr>
    <tr>
        <td>Model</td>
	<td><asp:TextBox ID="txtSearchModel" runat="server"></asp:TextBox></td>
    </tr>
    <tr>
        <td></td>
	<td><asp:Button ID="Button3" runat="server" Text="Search" OnClick="btnSearch_Click" /></td>
    </tr>
    </table>
    
    <hr />
			
    <asp:GridView ViewStateMode="Enabled" ID="gvSearchIEMI" runat="server" Visible="true">
    </asp:GridView>
</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>



And that is my Code Behind page.cs

C#
protected void btnSearch_Click(object sender, EventArgs e)
    {
        gvSearchIEMI.DataSource = csSearch.Searh_by_IEMI(txtSearchIEMI.Text, 
        txtSearchBrand.Text, txtSearchModel.Text);
        gvSearchIEMI.DataBind();
    }




and for the Database Query i am using BLL and this is my Query in .cs

C#
public static DataSet Searh_by_IEMI(string IEMI, string Brand, string Model)
    {
        string query = String.Format(@"Select  [S.No] as S.No, IEMI, Brand, Model, Price, Date,        
        Warranty, Company, Cost from tbl_mobile WHERE IEMI = '{0}' AND Brand = '{1}' AND Model =                  
       '{2}'", IEMI, Brand, Model);
        return DAL.SelectQuery(query);
    }
Posted
Updated 31-Jul-13 16:30pm
v4

You try code : GridView.AutoGenerateColumns = true

or add column by manual in markup file

XML
<columns> 
    <asp:boundfield datafield="ColumnName" headertext="HeaderName" sortexpression="HeaderName" />
    ...
</columns>


by Wengdeli
 
Share this answer
 
v2
Comments
Waleed Anjum Bangash 17-Aug-13 14:45pm    
Mr. Wengdeli your answer was very informative, But i have extra problem of validation but its solved now.

Thanks alot

Regards!

Waleed Anjum
HI,
i think problem is that you are binding dataset to gridview as DataSource.
Try like this,

C#
protected void btnSearch_Click(object sender, EventArgs e)
    {
        DataSet ds = csSearch.Searh_by_IEMI(txtSearchIEMI.Text,
        txtSearchBrand.Text, txtSearchModel.Text);
        if(ds!= null)
        {
             gvSearchIEMI.DataSource = ds.Tables[0];
             gvSearchIEMI.DataBind();
        }
    }
 
Share this answer
 
Comments
Waleed Anjum Bangash 17-Aug-13 14:46pm    
Mr. Harshil_Raval your answer was very informative, But i have extra problem of validation but its solved now.

Thanks alot

Regards!

Waleed Anjum

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900