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)
{
}
}
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)
{
}
}
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