Shashank Laxman
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebInterface.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click"/>
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebInterface
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//DropDownList1.Items.Add("MEDICAL");
//TextBox1.Text = "1Jan2000";
//TextBox2.Text = "2Jan2000";
//TextBox3.Text = "FEVER";
}
protected void Button1_Click(object sender, EventArgs e)
{
ConcurrentDictionary<string, string> MyDictionary = new ConcurrentDictionary<string, string>();
Company l = new Company();
List<string> lstComp = new List<string>();
lstComp.Add("admin-Krishna Softwares");
lstComp.Add("admin-abc");
lstComp.Add("ks1-Krishna Softwares");
lstComp.Add("ks1-Krishna Softwares");
foreach (var t in lstComp)
{
String[] y = t.Split('-');
string Company = "";
StringBuilder sb = new StringBuilder();
if (MyDictionary.ContainsKey("admin"))
{
if (MyDictionary.TryGetValue("admin", out Company))
{
sb.Append(Company + "," + y[1]);
MyDictionary.TryAdd(y[0], sb.ToString());
}
}
else if (MyDictionary.ContainsKey("ks1"))
{
if (MyDictionary.TryGetValue("ks1", out Company))
{
sb.Append(Company + "," + y[1]);
MyDictionary.TryAdd(y[0], sb.ToString());
}
}
else
MyDictionary.TryAdd(y[0], y[1]);
}
GridView1.DataSource = MyDictionary.Select(m => new { m.Key,m.Value});
GridView1.DataBind();
//l.LeaveType = DropDownList1.SelectedValue.Trim();
//l.FromDate = TextBox1.Text.Trim();
//l.ToDate = TextBox2.Text.Trim();
//l.Reason = TextBox3.Text.Trim();
//MyDictionary.TryAdd(l.FromDate, l);
//GridView1.DataSource = MyDictionary.Select(m => new { m.Value.LeaveType, m.Value.FromDate, m.Value.ToDate, m.Value.Reason });
//GridView1.DataBind();
}
public class Leave
{
public string LeaveType;
public string FromDate;
public string ToDate;
public string Reason;
}
public class Company
{
public string userid;
public string compname;
}
}
}