Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET Ajax C#4.0
I am having a AJAX tab container with 8 tabs in which the Tab1 contains a DDL which is getting populated from the Database.

When the user selects one particular value a query is called and the following 3 text boxes are filled with the relative data. As follows:
private void LoadEnqNos() 
    { 
        try 
        { 
            string cmd = "SELECT EnqRef, EnqNo FROM EnquiryDetails"; 
 
            SqlDataAdapter da = new SqlDataAdapter(cmd, conn); 
            DataTable table = new DataTable(); 
 
            da.Fill(table); 
 
            ddlEnqList.DataSource = table; 
            ddlEnqList.DataBind(); 
 
        } 
        catch (Exception ex) 
        { 
            // Handle the error 
        } 
 
    } 
 
    protected void ddlEnqList_SelectedIndexChanged(object sender, EventArgs e) 
    { 
 
        getDetails(); 
 
    } 
 
    private void getDetails() 
    { 
        DataTable details = new DataTable(); 
        try 
        { 
           SqlDataAdapter ad = new SqlDataAdapter("SELECT EnqTitle,ProjType,EnqType  
           FROM EnquiryDetails 
            WHERE EnqNo = '" + ddlEnqList.SelectedItem.Value + "'", conn); 
 
            ad.Fill(details); 
 
            if (details.Rows.Count > 0) 
            { 
                txtProjTitle.Text = details.Rows[0]["EnqTitle"].ToString(); 
                txtProjType.Text = details.Rows[0]["ProjType"].ToString(); 
                txtEnqType.Text = details.Rows[0]["EnqType"].ToString(); 
            } 
 
        } 
        catch (Exception ex) 
        { 
            // Handle the error 
        } 
 
    }
 
Now the problem is that the above code was not working and my text boxes were blank but suddenly it started working when I made the property EnableViewState="true" of Tab Container1, as given below:
 
<cc1:TabContainer ID="TabContainer1"  runat="server" ActiveTabIndex="0" Width="870px" Height="327px" FontUnderline="False" Enabled="true" EnableTheming="True" ScrollBars="Auto" EnableViewState="false" style="margin-left: 0px">
But to my surprise after making the value true for the view state I am not able to take input data from users in the following 2nd,3rd,.... Tabs which were working fine before that.
<cc1:TabPanel  runat="server" HeaderText="Deliverables" ID="TabPanel2">
                
<ContentTemplate>
<table style="width: 827px"><tr>
    <td style="width: 64px; height: 32px"></td>
    <td class="style5"><asp:Label ID="Label2" runat="server" Font-Bold="True" 
            Font-Names="Verdana" Font-Size="17px" Height="24px" style="text-align: right" 
            Text="Enter Project Deliverables Details" Width="508px"></asp:Label>
 

</td><td style="width: 49px; height: 32px"></td>
    </tr>
    <tr><td style="width: 64px; height: 13px;"></td><td class="style6"></td>
        <td style="width: 49px; height: 13px;"></td>
        <td style="width: 50px; height: 13px; text-align: center;"> </td></tr></table>
<table style="width: 828px; height: 182px;">
    <tr><td class="style14"> </td>
        <td style="width: 166px; height: 20px"> </td>
        <td class="style12"></td></tr>
    <tr><td class="style13"> </td>
        <td style="width: 166px; ">
                <asp:GridView ID="GridviewProjDeliverables" runat="server" 
           AutoGenerateColumns="False" OnRowCommand="GridviewProjDeliverables_RowCommand" >
                <RowStyle Font-Size="Smaller" />
                    <Columns><asp:TemplateField HeaderText="Delivery Item"><ItemTemplate>
                            <asp:TextBox ID="txtDitem" runat="server" Text='<%# Bind("Item") %>'>
                </asp:TextBox>
                </ItemTemplate></asp:TemplateField>
                        <asp:TemplateField HeaderText="Delivery Description">
                            <ItemTemplate><asp:TextBox ID="txtDesc" runat="server" Text='<%# Bind("Description") %>'>
                </asp:TextBox></ItemTemplate></asp:TemplateField>
                        <asp:TemplateField HeaderText="Quantity">
                            <ItemTemplate><asp:TextBox ID="txtQnty" runat="server" Text='<%# Bind("Quantity") %>'>
                </asp:TextBox></ItemTemplate></asp:TemplateField>
                        <asp:TemplateField HeaderText="Remarks">
                            <ItemTemplate><asp:TextBox ID="txtRemarks1" runat="server"   Text='<%# Bind("Remarks") %>'>
                </asp:TextBox></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Add"><ItemTemplate>
                                <asp:LinkButton ID="linkAdd" runat="server" 
                                CommandName="AddRow">Add</asp:LinkButton></ItemTemplate></asp:TemplateField>
                        <asp:TemplateField HeaderText="Remove">
                            <ItemTemplate>
                                <asp:LinkButton ID="linkRemove" runat="server" CausesValidation="false" 
                                    CommandName="remove">Remove</asp:LinkButton></ItemTemplate></asp:TemplateField></Columns>
                    <HeaderStyle Font-Size="XX-Small" /></asp:GridView>
 
 
And the code behind for that is....
 
public void SaveEstimationDetails() 
{ 
try 
{ 
conn.Open(); 
int intCnt = 0; 
 
for (int i = 0; i < GridviewProjDeliverables.Rows.Count; i++) 
{ 
TextBox txtDitem = (TextBox)GridviewProjDeliverables.Rows[i].Cells[0].FindControl("txtDitem"); 
TextBox txtDescription = (TextBox)GridviewProjDeliverables.Rows[i].Cells[1].FindControl("txtDesc"); 
TextBox txtQuantity = (TextBox)GridviewProjDeliverables.Rows[i].Cells[2].FindControl("txtQnty"); 
TextBox txtRemarks = (TextBox)GridviewProjDeliverables.Rows[i].Cells[3].FindControl("txtRemarks1"); 
 

After making the EnableViewState="true" my variables are not able to fetch the data inputed by user user and saying that the field is blank but if I am making it "false" then the controls on the Tabs are working fine but my drop down list functionality is not working... on Tab1..

So, Pls suggest some solution which will work for both the tabs proper functioning, without affecting their functionality.

 
thanks A lot in advance...
Tab1 with DDL
Tab2 with input boxes
Posted 29-May-12 22:10pm
Edited 1-Jun-12 2:56am
v4

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

hi,
I need more code for testing solution....
but, i've an alternative:
 
you can put getDetails() in a webservice (or PageMethod), put your 3 textbox bottom DDL in a Panel with DynamicPopulateExtender.
These are examples:
http://www.ajaxtutorials.com/ajax-control-toolkit-tutorials/ajax-control-toolkit-tutorails-using-dynamicpopulate-extender-c-asp-net/[^]
 
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/DynamicPopulate/DynamicPopulate.aspx[^]
 
http://www.asp.net/ajaxlibrary/HOW%20TO%20Use%20the%20DynamicPopulate%20Control.ashx[^]
  Permalink  
Comments
Ashishkumar Patel at 1-Jun-12 8:30am
   
If you can give me your email id then I'll send the project file to you.
My email is: ashkpatel@gmail.com
cpsglauco at 1-Jun-12 9:13am
   
cpsglauco [simbol here] yahoo [dot here] it

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



Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 1 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100