Tuesday, February 1, 2011

 Gridview Check all row C# and rember checked checkboxes after postback

 Gridview Check all row C# and rember checked checkboxes after postback
 
 
 <asp:GridView ID="gv" runat="server" Visible="false"></asp:GridView>

<asp:GridView ID="GridView1" runat="server" DataKeyNames="id"

AutoGenerateColumns="False" OnPageIndexChanging="GridView1_PageIndexChanging"

AutoGenerateEditButton="True"

OnRowCancelingEdit="gdview_RowCancelingEdit" AutoGenerateDeleteButton="True"

OnRowDeleting="gdview_RowDeleting" AllowSorting="True" OnSorting ="grdView_OnSorting"

OnRowEditing="gdview_RowEditing" OnRowUpdating="gdview_RowUpdating"

CellPadding="4" ForeColor="#333333" GridLines="None"

>

<AlternatingRowStyle BackColor="White" ForeColor="#284775" />

<Columns>

<asp:TemplateField HeaderText="Select">

<HeaderTemplate>

<!--<asp:CheckBox ID="chkSelectAll" runat="server" Text="Select&nbsp;All" AutoPostBack="true" OnCheckedChanged="chkSelectAll_CheckedChanged" />-->

<label id="heda" text="Select"></label>

</

HeaderTemplate>

<

ItemTemplate>

<

asp:CheckBox ID="CheckBoxVid" runat="server" />

</

ItemTemplate>

</

asp:TemplateField>

<asp:BoundField DataField="video_id" HeaderText="video_id" SortExpression="video_id" />

<

asp:BoundField DataField="content_type" HeaderText="content_type" SortExpression="content_type" />

<

asp:BoundField DataField="policy" HeaderText="policy" SortExpression="policy" />

<

asp:BoundField DataField="video_title" HeaderText="video_title" SortExpression="video_title" />

<

asp:BoundField DataField="video_duration" HeaderText="video_duration" SortExpression="video_duration" />

<

asp:BoundField DataField="username" HeaderText="username" SortExpression="username" />

<

asp:BoundField DataField="uploader" HeaderText="uploader" SortExpression="uploader" />

<

asp:BoundField DataField="claim_type" HeaderText="claim_type" SortExpression="claim_type" />

<

asp:BoundField DataField="claim_origin" HeaderText="claim_origin" SortExpression="claim_origin" />

<

asp:BoundField DataField="embed_views" HeaderText="embed_views" SortExpression="embed_views" />

<

asp:BoundField DataField="watch_views" HeaderText="watch_views" SortExpression="watch_views" />

<

asp:BoundField DataField="share_rev" HeaderText="share_rev" SortExpression="share_rev" />

<

asp:BoundField DataField="partner_sold_revenue" HeaderText="partner_sold_revenue" SortExpression="partner_sold_revenue" />

<

asp:BoundField DataField="afv_revenue" HeaderText="afv_revenue" SortExpression="afv_revenue" />

<

asp:BoundField DataField="amount_payable" HeaderText="amount_payable" SortExpression="amount_payable" />

<

asp:BoundField DataField="has_multiple_claims" HeaderText="has_multiple_claims" SortExpression="has_multiple_claims" />

<

asp:BoundField DataField="category" HeaderText="category" SortExpression="category" />

<

asp:BoundField DataField="custom_id" HeaderText="custom_id" SortExpression="custom_id" />

<

asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True" SortExpression="id" />

</Columns>

<EditRowStyle BackColor="#999999" />

<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />

<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />

<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />

<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />

<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />

<SortedAscendingCellStyle BackColor="#E9E7E2" />

<SortedAscendingHeaderStyle BackColor="#506C8C" />

<SortedDescendingCellStyle BackColor="#FFFDF8" />

<SortedDescendingHeaderStyle BackColor="#6F8DAE" />

</asp:GridView>

</

ContentTemplate>

</

asp:UpdatePanel>

protected void chkSelectAll_CheckedChanged(object sender, EventArgs e)

{

CheckBox cbHeader = (CheckBox)GridView1.HeaderRow.FindControl("chkSelectAll");

chkheadbx = cbHeader.Checked.ToString();

// Session["chxboxhd"] = chkheadbx;

// Response.Write(Session["chxboxhd"]);

CheckBox chk;

foreach (GridViewRow rowItem in GridView1.Rows)

{

chk = (

CheckBox)(rowItem.Cells[0].FindControl("CheckBoxVid"));

chk.Checked = ((

CheckBox)sender).Checked;

}

Session[

"chxboxhd"] = chkheadbx;

// Response.Write(Session["chxboxhd"]);

}

 

 

private void RememberOldValues()

{

ArrayList categoryIDList = new ArrayList();

int index = -1;

foreach (GridViewRow row in GridView1.Rows)

{

index = (

int)GridView1.DataKeys[row.RowIndex].Value;

bool result = ((CheckBox)row.FindControl("CheckBoxVid")).Checked;

// Check in the Session

if (Session[CHECKED_ITEMS] != null)

categoryIDList = (

ArrayList)Session[CHECKED_ITEMS];

if (result)

{

if (!categoryIDList.Contains(index))

categoryIDList.Add(index);

}

else

categoryIDList.Remove(index);

}

if (categoryIDList != null && categoryIDList.Count > 0)

Session[CHECKED_ITEMS] = categoryIDList;

}

private void RePopulateValues()

{

ArrayList categoryIDList = (ArrayList)Session[CHECKED_ITEMS];

if (categoryIDList != null && categoryIDList.Count > 0)

{

foreach (GridViewRow row in GridView1.Rows)

{

int index = (int)GridView1.DataKeys[row.RowIndex].Value;

if (categoryIDList.Contains(index))

{

CheckBox myCheckBox = (CheckBox)row.FindControl("CheckBoxVid");

myCheckBox.Checked =

true;

}

}

}

}

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)

{

RememberOldValues();

GridView1.PageIndex = e.NewPageIndex;

BindData();

RePopulateValues();

}

 

 

Friday, January 28, 2011

Dynamic Sql-srever - table column header name

Dynamic Sql-srever - table column header name
 
declare @colnm varchar(20)
declare @strsql varchar(2000)
set @colnm='1625195'
--set @strsql='select ['+  @colnm + '] from ia_book1 where ['+  @colnm + '] =''1625195'+''+char(39)
set @strsql='select * from ia_book1 where ['+  @colnm + '] ='+char(39)+@colnm +char(39)
Print @strsql
exec(@strsql)

JD Edwards IB Batch Error: The AA ledger type for 1/22/2011 , document xxxxxx is out of balance by xxxx.xx .

In JD Edwards batch fixing is a challance for each batch and each time is different. For same error you can fix different wy I fixed is IB batch error as following:-
1. Took backup for batch .
2. using sql updated F0911 all 'P' to blank in GLPOST field.
3. Ran batch post program R09801 and after that batch posted correctly.
4. Ran re-post program(R099102) for all related account (GLAID) in this batch.
 
 
 

Thursday, January 27, 2011

docs

Database:
1. vdcsvfl structure should be as same as table name: Reporting (Done).
2. All final data must be inserted into table name: Reporting.
(Done with new date field)
3. All SQL Statement must be converted into Stored Procedure.
(Done)
Web:
1. Add CheckAll Checkbox so once it is checked, all checkboxes will be
checked.(Done)
2. Add AllowSorted in Gridview equal to true.(Done)
3. The Submit button <<next the browse>> should not be shown until
the browse textbox has value. (Not yet)
5. Delete proddta.aspx. We don't need it. Reporting.aspx will show all
information from Reporting table.
(done) in case you want to see Data for reporting table I am not
deleting this program. If you want to use you can use.
6. Validate the value when it is updated. At least check if it is empty.(Done)
Checking if file is .csv or not. If no file selected won't do anything.
7. <<A favor>> Please add textbox and it is a date field. I need this
date field saved into Reporting Table.
Done.
A date field called ReportingDate will be created in the Reporting table.

DateTime formate C#,vb asp.net 4.0

DateTime.Now; 1/27/2011 11:22:45 AM
DateTime.Now.ToString(); 1/27/2011 11:22:45 AM
DateTime.Now.ToShortTimeString() 11:22 AM
DateTime.Now.ToShortDateString() 1/27/2011
DateTime.Now.ToLongTimeString() 11:22:45 AM
DateTime.Now.ToLongDateString() Thursday, January 27, 2011





DateTime.Now.ToString("d")
 
1/27/2011
DateTime.Now.ToString("D")
 
Thursday, January 27, 2011
DateTime.Now.ToString("f")
 
Thursday, January 27, 2011 11:22 AM
DateTime.Now.ToString("F")
 
Thursday, January 27, 2011 11:22:45 AM
DateTime.Now.ToString("g")
 
1/27/2011 11:22 AM
DateTime.Now.ToString("G")
 
1/27/2011 11:22:45 AM
DateTime.Now.ToString("m")
 
January 27
DateTime.Now.ToString("r")
 
Thu, 27 Jan 2011 11:22:45 GMT
DateTime.Now.ToString("s")
 
2011-01-27T11:22:45
DateTime.Now.ToString("t")
 
11:22 AM
DateTime.Now.ToString("T")
 
11:22:45 AM
DateTime.Now.ToString("u")
 
2011-01-27 11:22:45Z
DateTime.Now.ToString("U")
 
Thursday, January 27, 2011 5:22:45 PM
DateTime.Now.ToString("y")
 
January, 2011
DateTime.Now.ToString("dddd, MMMM dd yyyy")
 
Thursday, January 27 2011
DateTime.Now.ToString("ddd, MMM d "'"yy")
 
Thu, Jan 27 '11
DateTime.Now.ToString("dddd, MMMM dd")
 
Thursday, January 27
DateTime.Now.ToString("M/yy")
 
1/11
DateTime.Now.ToString("dd-MM-yy")
 
27-01-11

 

 
 

checkbox c# check all

http://programming.top54u.com/post/ASP-Net-GridView-Checkbox-Select-All-using-C-sharp.aspx

csv file upload csv ,net c#

Csv file upload csv ,net c#, validate file before upload
 
 
if (FileUpLoad1.HasFile)

{

string filePath = FileUpLoad1.PostedFile.FileName;

string filenameStor = FileUpLoad1.FileName;

string filenameType = Path.GetExtension(FileUpLoad1.PostedFile.FileName);

if (filenameType.ToString().Trim().ToLower() == ".csv")

{

FileUpLoad1.SaveAs(@"c:\\sites\\" + "Book1.csv");

lblStatus.Text = "File Uploaded : " + FileUpLoad1.PostedFile.FileName;

insFileName();

SqlDataSource1.SelectCommand = "SELECT * FROM vdcsvfl";

gvid.Visible = true;

Button1.Visible = true;

}

else

{

lblStatus.Text =

"Invalid File Type...";

}

}

else

{

lblStatus.Text =

"No File Uploaded.";

gvid.Visible =

true;

Button1.Visible =

true;

}

}

void insFileName()

{

SqlConnection myConnection = new SqlConnection(ConnectionString);

string strSQL;

strSQL =

"insbulkcsvP";

SqlCommand cmd = new SqlCommand(strSQL, myConnection);

cmd.CommandType =

CommandType.StoredProcedure;

 myConnection.Open();

cmd.ExecuteNonQuery();

myConnection.Close();

lblStatus.Text =

"Added..";
}
 
 
 

ALTER

proc [dbo].[insbulkcsvP] as

delete

from dbo.vdcsvfl

Alter

Table vdcsvfl Drop Column id

--ALTER TABLE a DROP COLUMN y

BULK

INSERT dbo.vdcsvfl

FROM

'c:\sites\Book1.csv'

WITH

(

FIELDTERMINATOR

= ',',

ROWTERMINATOR

= '\n'

)

delete

from dbo.vdcsvfl where video_id='video_id'

Alter

Table vdcsvfl Add id int identity(1,1) --primary key

Wednesday, January 26, 2011

Find & Replace Sql-server update

UPDATE dbo.states
SET    adds = replace([city], 'Bihar', 'Jharkhand')
WHERE  adds LIKE 'Bihar%';

Tuesday, January 25, 2011

Godaddy Hosting Account's Absolute Path

To Find Your Absolute Hosting Path

  1. Log in to your Account Manager.
  2. From the Products section, click Web Hosting.
  3. Next to the hosting account you want to use, click Launch.
In the Server section, your hosting account's Absolute Hosting Path displays.
 

Alter table add identity column

If there is exising filed you want to change
Alter
Table temp_inscsv Drop Column id
 
if not want to add a brand new use pnly following:-
Alter Table temp_inscsv Add id int identity(1,1) primary key

'1,2,3,4' sql-server - Split Function in Sql Server to break Comma-Separated Strings into Table

CREATE FUNCTION dbo.Split(@String varchar(8000), @Delimiter char(1))
returns @temptable TABLE (items varchar(8000))
as
begin
declare @idx int
declare @slice varchar(8000)

select @idx = 1
if len(@String)<1 or @String is null return

while @idx!= 0
begin
set @idx = charindex(@Delimiter,@String)
if @idx!=0
set @slice = left(@String,@idx - 1)
else
set @slice = @String

if(len(@slice)>0)
insert into @temptable(Items) values(@slice)

set @String = right(@String,len(@String) - @idx)
if len(@String) = 0 break
end
return
end


select top 10 * from dbo.split('Chennai,Bangalore,Mumbai',',')
http://www.logiclabz.com/sql-server/split-function-in-sql-server-to-break-comma-separated-strings-into-table.aspx