Friday, September 7, 2007
Upload a file in Window application
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
FileInfo f = new FileInfo(openFileDialog1.FileName);
string[] fName;
fName = openFileDialog1.FileName.Split(new char[] {'\\'} );
f.CopyTo("C:\\Bharathi\\" + fName[fName.Length-1]);
FileStream fs = new FileStream("C:\\Bharathi\\" + fName[fName.Length - 1], FileMode.Open);
StreamReader sr = new StreamReader(fs);
MessageBox.Show(sr.ReadToEnd());
//System.IO.File.ReadAllBytes(openFileDialog1.FileName);
}
VB.NET + ASP.NET + Data Grid + V1.x
<asp:datagrid id="dgUserCampaigns" DataKeyField="UserCampaignId" runat="server" CssClass="bordergrid"
AllowSorting="True" GridLines="Horizontal" ShowHeader="False" AutoGenerateColumns="False"
CellPadding="3" AllowPaging="False" Width="100%">
<ItemStyle Height="20px" CssClass="GridItem"></ItemStyle>
<HeaderStyle HorizontalAlign="Left" Height="22px" CssClass="GridHeader" Font-Bold="True" VerticalAlign="Middle"></HeaderStyle>
<FooterStyle Height="18px"></FooterStyle>
<Columns>
<asp:BoundColumn Visible="False"></asp:BoundColumn>
<asp:TemplateColumn Visible="False">
<ItemStyle Width="0%" HorizontalAlign="Center"></ItemStyle>
<HeaderTemplate>
<asp:linkbutton Runat="server" ID="lnkCreatedDate" CssClass="gridheaderlink" Font-Bold="True" CommandName="sort"
CommandArgument="CreatedDate">Created</asp:linkbutton>
</HeaderTemplate>
<ItemTemplate>
<asp:Label Runat="server" CssClass="fontblue" ID="lblCreatedDate" text='<%# GenValidations.GetDateValue(Databinder.Eval(container.Dataitem,"CreatedDate"))%>' >
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="False">
<ItemStyle Width="0%" HorizontalAlign="left"></ItemStyle>
<HeaderTemplate>
Type
</HeaderTemplate>
<ItemTemplate>
<asp:Label Runat="server" CssClass="fontblue" ID="lblType" text='<%# Databinder.Eval(container.Dataitem,"TemplateType")%>' >
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="False">
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle Width="0%" HorizontalAlign="Center"></ItemStyle>
<HeaderTemplate>
Draft
</HeaderTemplate>
<ItemTemplate>
<asp:Image ID="imgDraft" ImageUrl="../Images/status.gif" BorderWidth="0" Runat="server" Visible='false'></asp:Image>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="false">
<ItemStyle Width="0%" HorizontalAlign="Center"></ItemStyle>
<HeaderTemplate>
Scheduled
</HeaderTemplate>
<ItemTemplate>
<asp:Image ID="imgScheduled" ImageUrl="../Images/status.gif" BorderWidth="0" Runat="server"
Visible=''></asp:Image>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="False">
<ItemStyle Width="0%" HorizontalAlign="Center"></ItemStyle>
<HeaderTemplate>
Send
</HeaderTemplate>
<ItemTemplate>
<asp:Image ID="imgSent" ImageUrl="../Images/status.gif" BorderWidth="0" Runat="server" Visible='false'></asp:Image>
<asp:Label id="lblSend" Runat="server" visible="False" text=''></asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="False">
<ItemStyle Width="0%" HorizontalAlign="Center"></ItemStyle>
<HeaderTemplate>
Delivered
</HeaderTemplate>
<ItemTemplate>
<asp:Image ID="imgDelivered" ImageUrl="../Images/status.gif" BorderWidth="0" Runat="server"
Visible='false'></asp:Image>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="False">
<ItemStyle Width="0%"></ItemStyle>
<HeaderTemplate>
<asp:linkbutton Runat="server" ID="lnkDeliveryDate" CssClass="gridheaderlink" Font-Bold="True" CommandName="sort"
CommandArgument="DeliveryDate">Delivery Date</asp:linkbutton>
</HeaderTemplate>
<ItemTemplate>
<asp:Label Runat="server" CssClass="fontblue" ID="lblDeliveryDate" text='<%# Databinder.Eval(container.Dataitem,"DeliveryDate","{0:MM/dd/yyyy}")%>' >
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="False">
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle Width="0%" HorizontalAlign="Center"></ItemStyle>
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton Runat="server" ID="lnkEditMail" CommandName="Email">
<img src="../Images/mail.gif" border="0">
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="False">
<ItemStyle Width="0%" HorizontalAlign="Center"></ItemStyle>
<HeaderTemplate>
<asp:linkbutton Runat="server" ID="lnkCampaignStatus" CssClass="gridheaderlink" Font-Bold="True"
CommandName="sort" CommandArgument="CampaignStatus">Status</asp:linkbutton>
</HeaderTemplate>
<ItemTemplate>
<asp:Label Runat="server" CssClass="fontblue" ID="lblCampaignStatus" ForeColor='<%# GenValidations.GetCampaignStatusColor(Databinder.Eval(container.Dataitem,"CampaignStatus"))%>' text='<%# GenValidations.GetCampaignStatus(Databinder.Eval(container.Dataitem,"CampaignStatus"))%>' >
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="False">
<ItemStyle Width="0%" HorizontalAlign="left"></ItemStyle>
<HeaderTemplate>
Campaign Description
</HeaderTemplate>
<ItemTemplate>
<asp:Label Runat="server" CssClass="fontblue" ID="lblCampaignDescription" Visible=False text='<%# Databinder.Eval(container.Dataitem,"CampaignDescription")%>' >
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle Width="9%" HorizontalAlign="Center"></ItemStyle>
<HeaderTemplate>
<asp:CheckBox Runat="server" ID="chkCheckAll" CssClass="font1"></asp:CheckBox>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox Runat="server" ID="chk1" CssClass="font1"></asp:CheckBox>
<asp:TextBox ID="txtUserCampaignId" CssClass="gridlink" Runat=server text='<%# Databinder.Eval(container.Dataitem,"UserCampaignId")%>' style="Width:0;Height:0;visibility:hidden">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<HeaderStyle></HeaderStyle>
<ItemStyle Width="28%"></ItemStyle>
<HeaderTemplate>
<asp:linkbutton Runat="server" ID="lnkCampaignSort" CssClass="gridheaderlink" Font-Bold="True" CommandName="sort"
CommandArgument="CampaignName">Campaigns <img src="../Images/arrdown.gif" border="0"></asp:linkbutton>
</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton id="lnkCampaignName" CssClass="gridlink" tooltip='<%# Databinder.Eval(container.Dataitem,"CampaignName")%>' text='<%# Genvalidations.GetStringValueWithwrap(Databinder.Eval(container.Dataitem,"CampaignName"),18)%>' Runat="server" CommandName="Summary">
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemStyle Width="10%" HorizontalAlign="Center"></ItemStyle>
<HeaderTemplate>
<asp:linkbutton Runat="server" ID="Linkbutton1" CssClass="gridheaderlink" Font-Bold="True" CommandName="sort"
CommandArgument="CampaignStatus">Status</asp:linkbutton>
</HeaderTemplate>
<ItemTemplate>
<asp:Label Runat="server" CssClass="fontblue" ID="Label1" text='<%# GenValidations.GetDateValue(Databinder.Eval(container.Dataitem,"CreatedDate"))%>' >
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:ButtonColumn Visible="False" Text="Edit" HeaderText="Edit" CommandName="Edit">
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" Width="8%" CssClass="gridlink" VerticalAlign="Middle"></ItemStyle>
</asp:ButtonColumn>
<asp:TemplateColumn>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle Width="10%" HorizontalAlign="center"></ItemStyle>
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<asp:ImageButton ID="imgCampaignSummary" Runat="server" ImageUrl="../Images/Zoom.gif" BorderWidth="0"
CommandName="Summary"></asp:ImageButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle Width="9%" HorizontalAlign="Center"></ItemStyle>
<HeaderTemplate>
Edit
</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton Runat="server" ID="lnkEditMessage" CommandName="Edit">
<img src="../Images/Edit.gif" border="0">
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle Width="9%" HorizontalAlign="Center"></ItemStyle>
<HeaderTemplate>
Delete
</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton Runat="server" ID="lnkDelete" CommandName="Delete">
<img src="../Images/Delete.gif" border="0">
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle Width="9%" HorizontalAlign="Center"></ItemStyle>
<HeaderTemplate>
Summary
</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton Runat="server" ID="lnkSummary" CommandName="Summary">
<img src="../Images/book.gif" border="0">
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
Subscribe to:
Posts (Atom)