Click here to Skip to main content
16,016,229 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
private void button2_Click_1(object sender, EventArgs e)
{
if (textBox3.Text == "Hutatma express")
{
SqlCommand cm1 = new SqlCommand("Select * from hutatma", con);
DataTable dth = new DataTable();
SqlDataAdapter da = new SqlDataAdapter();
da.Fill(dth);
dataGridView1.DataSource = dth;
cmd1 = new SqlCommand("select * from traintime", con);
}
else if (textBox3.Text == "Sewagram express")
{
SqlCommand cm1 = new SqlCommand("select * from sewagram", con);
DataTable dth = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cm1);
da.Fill(dth);
dataGridView1.DataSource = dth;
Image image1 = Image.FromFile(@"D:\asp.net practice\mindicator\mindicator\image\sevagram exp12.jpg");
label3.Image = image1;

}
else if (textBox3.Text == "Vidarbha express")
{
SqlCommand cm1 = new SqlCommand("select * from vidarbha", con);
DataTable dth = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cm1);
da.Fill(dth);
dataGridView1.DataSource = dth;
Image image1 = Image.FromFile(@"D:\asp.net practice\mindicator\mindicator\image\Vidarbha_Express.jpg");
label3.Image = image1;
}
else
{
MessageBox.Show("Enter Correct Name");
}
}
Posted

1 solution

You can do that in aspx file.

XML
<asp:GridView ID="searchProductGridView" runat="server" AutoGenerateColumns="false" DataKeyNames="ProductCode"
                        CssClass="gridview" AlternatingRowStyle-CssClass="alternatingRow" AllowPaging="true" PagerStyle-CssClass="paging" OnPageIndexChanging="searchProductGridView_PageIndexChanging">
                        <Columns>
                            <asp:TemplateField HeaderText="Select">
                                <ItemTemplate>
                                    <asp:CheckBox ID="selectChkBox" runat="server" ToolTip="Add to Cart" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Code" ControlStyle-Width="150px">
                                <ItemTemplate>
                                    <asp:LinkButton ID="codeLink" runat="server" Font-Size="9" ForeColor="#1C329F" CssClass="link" Font-Underline="false"
                                        Text='<%#Eval("ProductCode") %>' OnClick="codeLink_Click" />
                                </ItemTemplate>
                            </asp:TemplateField>

and .aspx.cs file :
 
Share this answer
 
Comments
Abhinav Chaudhary 16-Feb-14 2:48am    
so i cant do it in windows forms application?
Krunal Rohit 16-Feb-14 2:50am    
private void Form1_Load(object sender, EventArgs e)
{
DataGridViewLinkCell successCell = new DataGridViewLinkCell();
successCell.Value = "Success";
successCell.LinkBehavior = LinkBehavior.NeverUnderline;
successCell.LinkColor = Color.Black;
successCell.LinkVisited = false;
successCell.TrackVisitedState = false;

this.dataGridView1.Rows.Add(2);
this.dataGridView1[0, 0].Value = "Error";

this.dataGridView1[0, 1] = successCell;
}

See this

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