Hi kankon,
Check this sample. now take its reference and correct your code.
you need give expression for that column textbox in report.rdlc
i.e
=IIf(Fields!Country.Value = "USA", "ریاستہائے متحدہ",
IIf(Fields!Country.Value = "Austria","آسٹریا",
IIf(Fields!Country.Value = "UK", "متحدہ سلطنت یونائیٹڈ کنگڈم", Fields!Country.Value)
)
)
HTML
<asp:DropDownList ID="ddlCountries" runat="server" OnSelectedIndexChanged="SelectedCountryChanged"
AutoPostBack="true" Font-Size="Large">
<asp:ListItem Text="All" Value="" />
<asp:ListItem Text="مهندس كهرباء" Value="Austria" />
<asp:ListItem Text="اشرافي/ مساعد مهندس (كهرباء)" Value="France" />
<asp:ListItem Text="فني كهرباء" Value="Brazil" />
<asp:ListItem Text="مهندس مدني" Value="Ireland" />
<asp:ListItem Text="اشرافي/ مساعد مهندس مدني" Value="Italy" />
<asp:ListItem Text="فني مدني" Value="Finland" />
<asp:ListItem Text="مهندس ميكانيك" Value="mechanical1" />
<asp:ListItem Text="اشرافي/ مساعد مهندس ميكانيك" Value="mechanical2" />
<asp:ListItem Text="فني ميكاكنيك" Value="mechanical3" />
<asp:ListItem Text="مهندس زراعة / نظافة / خدمات فندقية" Value="adaptation1" />
<asp:ListItem Text="اشرافي/ مساعد مهندس زراعة / نظافة / خدمات فندقية" Value="adaptation2" />
<asp:ListItem Text="فني زراعة / نظافة / خدمات فندقية" Value="adaptation3" />
<asp:ListItem Text="مهندس حاسوب / الكترونيات / اتصالات" Value="computer1" />
<asp:ListItem Text="اشرافي/ مساعد مهندس حاسوب / الكترونيات / اتصالات" Value="computer2" />
<asp:ListItem Text="فني حاسوب / الكترونيات / اتصالات" Value="computer3" />
</asp:DropDownList>
<hr />
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Width="500" SizeToReportContent="true"
ZoomMode="PageWidth">
</rsweb:ReportViewer>
Namespaces
C#
using System.Configuration;
using System.Data.SqlClient;
using Microsoft.Reporting.WebForms;
VB.Net
Imports System.Configuration
Imports System.Data.SqlClient
Imports Microsoft.Reporting.WebForms
Code
C#
private void BindReport()
{
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc");
Customers dsCustomers = GetData(ddlCountries.SelectedItem.Value);
ReportDataSource datasource = new ReportDataSource("Customers", dsCustomers.Tables[0]);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(datasource);
}
protected void SelectedCountryChanged(object sender, EventArgs e)
{
this.BindReport();
}
private Customers GetData(string country)
{
string conString = ConfigurationManager.ConnectionStrings["NORTHWINDConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(conString))
{
using (SqlCommand cmd = new SqlCommand("SELECT CustomerID,ContactName,City,Country FROM Customers WHERE Country = @Country OR @Country IS NULL", con))
{
cmd.Parameters.AddWithValue("@Country", !string.IsNullOrEmpty(country) ? country : (object)DBNull.Value);
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
using (Customers dsCustomers = new Customers())
{
sda.Fill(dsCustomers, "DataTable1");
return dsCustomers;
}
}
}
}
}
VB.Net
Private Sub BindReport()
ReportViewer1.ProcessingMode = ProcessingMode.Local
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc")
Dim dsCustomers As Customers = GetData(ddlCountries.SelectedItem.Value)
Dim datasource As ReportDataSource = New ReportDataSource("Customers", dsCustomers.Tables(0))
ReportViewer1.LocalReport.DataSources.Clear()
ReportViewer1.LocalReport.DataSources.Add(datasource)
End Sub
Protected Sub SelectedCountryChanged(ByVal sender As Object, ByVal e As EventArgs)
Me.BindReport()
End Sub
Private Function GetData(ByVal country As String) As Customers
Dim conString As String = ConfigurationManager.ConnectionStrings("NORTHWINDConnectionString").ConnectionString
Using con As SqlConnection = New SqlConnection(conString)
Using cmd As SqlCommand = New SqlCommand("SELECT CustomerID,ContactName,City,Country FROM Customers WHERE Country = @Country OR @Country IS NULL", con)
cmd.Parameters.AddWithValue("@Country", If(Not String.IsNullOrEmpty(country), country, CObj(DBNull.Value)))
Using sda As SqlDataAdapter = New SqlDataAdapter(cmd)
Using dsCustomers As Customers = New Customers()
sda.Fill(dsCustomers, "DataTable1")
Return dsCustomers
End Using
End Using
End Using
End Using
End Function
Screenshot
in your case the expression will be.
=IIf(Fields!BlockSpecial.Value = "electrical1", "مهندس كهرباء",
IIf(Fields!BlockSpecial.Value = "electrical2","اشرافي/ مساعد مهندس كهرباء",
IIf(Fields!BlockSpecial.Value = "electrical3", "فني كهرباء", Fields!BlockSpecial.Value)
)
)