sqlStr = "select EventID as EventID,EventName as EventName from EventsAutoTweet";
Ds = objConAT.SelectDataset(sqlStr, "EventTable");
//Ds.Tables[0].TableName = "EventTable";
//SentenceDeli,ShortUrlDeli
sqlStr = "select * from StoryStructure";
DataSet Ds2 = objConAT.SelectDataset(sqlStr, "StoryStructure")
Ds.Tables.Add( Ds2.Tables[0].Copy());
Wednesday, March 10, 2010
copy DataColumn to string Array
Step to copy the DataColumn values to string array.
string[] rowValuesForColumn = Array.ConvertAll<DataRow, string>(dsURLs.Tables[0].Select(), delegate(DataRow row) { return (string)row["feedURL"]; });
string[] rowValuesForColumn = Array.ConvertAll<DataRow, string>(dsURLs.Tables[0].Select(), delegate(DataRow row) { return (string)row["feedURL"]; });
Wednesday, February 24, 2010
Image Control
private string IMAGEurl(out bool b)
{
string saveLocation = ""; b = false;
string imageurl = "/images/thumbnail/UnknownSuper.gif";
try
{
string imageName = File1.PostedFile.FileName.Substring(File1.PostedFile.FileName.LastIndexOf("\\") + 1);
string extention = File1.PostedFile.FileName.Substring(File1.PostedFile.FileName.LastIndexOf("."));
saveLocation = string.Empty;
saveLocation = Server.MapPath("/images/user");
imageName = txtUsername.Text.ToString() + extention;
saveLocation = saveLocation + "/" + imageName;
// jerry 01-07-2009
Bitmap photo = objvalid.ResizeImage(File1.PostedFile.InputStream, 300, 300);// width height
photo.Save(saveLocation);
//
// File1.PostedFile.SaveAs(saveLocation);
saveLocation = string.Empty;
saveLocation = Server.MapPath("/images/thumbnail");
saveLocation = saveLocation + "/" + imageName;
Bitmap photoFile = objvalid.ResizeImage(File1.PostedFile.InputStream, 64, 64);// width height
photoFile.Save(saveLocation);
if (photoFile.Height > photoFile.Width)
b = true;
imageurl = "/images/thumbnail/" + imageName;
}
catch
{ }
return imageurl;
}
showing using:<img border=0 src=" + thumbImg + " />
{
string saveLocation = ""; b = false;
string imageurl = "/images/thumbnail/UnknownSuper.gif";
try
{
string imageName = File1.PostedFile.FileName.Substring(File1.PostedFile.FileName.LastIndexOf("\\") + 1);
string extention = File1.PostedFile.FileName.Substring(File1.PostedFile.FileName.LastIndexOf("."));
saveLocation = string.Empty;
saveLocation = Server.MapPath("/images/user");
imageName = txtUsername.Text.ToString() + extention;
saveLocation = saveLocation + "/" + imageName;
// jerry 01-07-2009
Bitmap photo = objvalid.ResizeImage(File1.PostedFile.InputStream, 300, 300);// width height
photo.Save(saveLocation);
//
// File1.PostedFile.SaveAs(saveLocation);
saveLocation = string.Empty;
saveLocation = Server.MapPath("/images/thumbnail");
saveLocation = saveLocation + "/" + imageName;
Bitmap photoFile = objvalid.ResizeImage(File1.PostedFile.InputStream, 64, 64);// width height
photoFile.Save(saveLocation);
if (photoFile.Height > photoFile.Width)
b = true;
imageurl = "/images/thumbnail/" + imageName;
}
catch
{ }
return imageurl;
}
showing using:<img border=0 src=" + thumbImg + " />
Gridveiw:Get all rows in one click
METHOD 1
===========================================
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{
Label5.Visible = true;
if (e.CommandName == "SET")
{
int IsFake = 0;
for (int i = 0; i < GridView1.Rows.Count; i++)
{
int userid = int.Parse(GridView1.Rows[i].Cells[0].Text.ToString());
CheckBox chbTemp = GridView1.Rows[i].FindControl("chkBxSelect") as CheckBox;
if (chbTemp.Checked)
{
// Response.Write(GridView1.Rows[i].Cells[0].Text + "<BR>");
IsFake = 1;
}
UpdateTheDetails(userid, IsFake);
IsFake = 0;
}
Label5.Visible = true;
Label5.Text = "Success..Marked the Fake Members Successfully..";
Label5.BackColor = Color.Yellow;
Label5.ForeColor = Color.Green;
}
}
catch { }
}
================================================================
METHOD 2
=================================================================
protected void btnSubmit_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows) //GridView1.PageSize * GridView1.PageCount
{
int IsFake = 0;
//Label lfilName = (Label)row.FindControl("lblfilename");
int userid = int.Parse(row.Cells[0].Text.ToString());
CheckBox chbTemp = (CheckBox)row.FindControl("chkBxSelect");
if (chbTemp.Checked)
{
IsFake = 1;
}
UpdateTheDetails(userid, IsFake);
IsFake = 0;
}
Label5.Visible = true;
Label5.Text = "Success..Marked the Fake Members Successfully..";
Label5.BackColor = Color.Yellow;
Label5.ForeColor = Color.Green;
}
===========================================
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{
Label5.Visible = true;
if (e.CommandName == "SET")
{
int IsFake = 0;
for (int i = 0; i < GridView1.Rows.Count; i++)
{
int userid = int.Parse(GridView1.Rows[i].Cells[0].Text.ToString());
CheckBox chbTemp = GridView1.Rows[i].FindControl("chkBxSelect") as CheckBox;
if (chbTemp.Checked)
{
// Response.Write(GridView1.Rows[i].Cells[0].Text + "<BR>");
IsFake = 1;
}
UpdateTheDetails(userid, IsFake);
IsFake = 0;
}
Label5.Visible = true;
Label5.Text = "Success..Marked the Fake Members Successfully..";
Label5.BackColor = Color.Yellow;
Label5.ForeColor = Color.Green;
}
}
catch { }
}
================================================================
METHOD 2
=================================================================
protected void btnSubmit_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows) //GridView1.PageSize * GridView1.PageCount
{
int IsFake = 0;
//Label lfilName = (Label)row.FindControl("lblfilename");
int userid = int.Parse(row.Cells[0].Text.ToString());
CheckBox chbTemp = (CheckBox)row.FindControl("chkBxSelect");
if (chbTemp.Checked)
{
IsFake = 1;
}
UpdateTheDetails(userid, IsFake);
IsFake = 0;
}
Label5.Visible = true;
Label5.Text = "Success..Marked the Fake Members Successfully..";
Label5.BackColor = Color.Yellow;
Label5.ForeColor = Color.Green;
}
Thursday, December 31, 2009
Stored procedure:Out put Parameter..using @@rowcount
Please check the below example:
alter PROCEDURE UpdateLogin
@UserName nvarchar(15),
@UpdateCount int OUTPUT
AS
update login set username=@UserName where userid<4
select @UpdateCount = @@rowcount
RETURN @UpdateCount
DECLARE @TheCount INT
exec UpdateLogin @UserName = 'sa', @UpdateCount = @TheCount OUTPUT
SELECT TheCount = @TheCount
alter PROCEDURE UpdateLogin
@UserName nvarchar(15),
@UpdateCount int OUTPUT
AS
update login set username=@UserName where userid<4
select @UpdateCount = @@rowcount
RETURN @UpdateCount
DECLARE @TheCount INT
exec UpdateLogin @UserName = 'sa', @UpdateCount = @TheCount OUTPUT
SELECT TheCount = @TheCount
DataGrid--->Sample for Accessing no of row for a 'Single Click'
CODE PART..
//The links important..
http://www.codedigest.com/Articles/ASPNET/132_GridView_with_CheckBox_%E2%80%93_Select_All_and_Highlight_Selected_Row.aspx
http://ramanisandeep.wordpress.com/tag/checkuncheck-all-items-in-an-asp-net-checkbox-list-using-jquery/
http://fun2code.blogspot.com/
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Connection;
public partial class FakeMemberMark : System.Web.UI.Page
{
ClsConnection objCon = new ClsConnection();
string sqlStr = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
try
{
//Session["adminloginname"] = "satheesh";
Label5.Visible = false;
if ((string)Session["adminloginname"] != null)
{
if (!IsPostBack)
{
lblcaption.Text = "Admin � Fake Member Marking";
Label2.Text = "[ Hi, " + Session["adminloginname"].ToString() + "| <a href=adminwelcome.aspx>Control panel</a> | <a href=adminlogout.aspx >Logout</a> ]";
loadGrid();
}
}
else
{
Response.Redirect("adminlogin.aspx");
}
}
catch
{
Response.Redirect("adminlogin.aspx");
}
}
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
//if (e.Row.RowType == DataControlRowType.DataRow && (e.Row.RowState ==DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate))
//{
// CheckBox chkBxSelect = (CheckBox)e.Row.Cells[1].FindControl("chkBxSelect");
// CheckBox chkBxHeader = (CheckBox)this.GridView1.HeaderRow.FindControl("chkAll");
// chkBxSelect.Attributes["onclick"] = string.Format("javascript:ChildClick(this,'{0}');",chkBxHeader.ClientID);
//}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lblIsFake = (Label)e.Row.FindControl("lblIsFake");
string IsFake = lblIsFake.Text.Trim().ToString();
CheckBox chkBxSelect = (CheckBox)e.Row.FindControl("chkBxSelect");
if (IsFake == "True")
{
chkBxSelect.Checked = true;
}
else
{
chkBxSelect.Checked = false;
}
try
{
HyperLink Hyperphotourl = (HyperLink)e.Row.FindControl("Hyperphotourl");
string HomeUrl = "http://" + HttpContext.Current.Request.Url.Host.ToString();//
string photourl = HomeUrl + "/" + Hyperphotourl.ImageUrl.ToString();
Hyperphotourl.ImageUrl = photourl;
Label lblusername = (Label)e.Row.FindControl("lblusername");
Hyperphotourl.NavigateUrl = "../" + lblusername.Text.ToString() + "/profile";
}
catch
{
}
}
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{
Label5.Visible = true;
if (e.CommandName == "SET")
{
int IsFake = 0;
for (int i = 0; i < GridView1.Rows.Count; i++)
{
int userid = int.Parse(GridView1.Rows[i].Cells[0].Text.ToString());
CheckBox chbTemp = GridView1.Rows[i].FindControl("chkBxSelect") as CheckBox;
if (chbTemp.Checked)
{
// Response.Write(GridView1.Rows[i].Cells[0].Text + "<BR>");
IsFake = 1;
}
UpdateTheDetails(userid, IsFake);
}
Label5.Visible = true;
Label5.Text = "Success..Marked the Fake Members Successfully..";
}
}
catch { }
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows) //GridView1.PageSize * GridView1.PageCount
{
int IsFake = 0;
//Label lfilName = (Label)row.FindControl("lblfilename");
int userid = int.Parse(row.Cells[0].Text.ToString());
CheckBox chbTemp = (CheckBox)row.FindControl("chkBxSelect");
if (chbTemp.Checked)
{
IsFake = 1;
}
UpdateTheDetails(userid, IsFake);
}
Label5.Visible = true;
Label5.Text = "Success..Marked the Fake Members Successfully..";
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
Label5.Visible = false;
GridView1.PageIndex = e.NewPageIndex;
loadGrid();
}
//the functions listed below...................
private bool UpdateTheDetails(int userid, int IsFake)
{
bool status = false;
try
{
sqlStr = "Update membersetting set IsFake=" + IsFake + " where userid=" + userid;
if (objCon.SqlExecuteQuery(sqlStr) == "Success")
{
status = true;
}
}
catch { }
return status;
}
private void loadGrid()
{
GridView1.Visible = false;
try
{
DataSet ds = GetUserDetails();
if (ds.Tables[0].Rows.Count > 0)
{
GridView1.DataSource = ds;
GridView1.DataBind();
GridView1.Visible = true;
}
else
{
Label5.Visible = true;
Label5.Text = "Sorry No User Details found";
}
}
catch
{
}
}
public DataSet GetUserDetails()
{
DataSet ds = new DataSet();
try
{
string sqlStr = "select l.userid,l.username,m.firstname,m.email,r.photourl,isnull(ms.IsFake,0) as IsFake from membermaildetails m,login l,registration r,membersetting ms where l.userid= m.loginid and r.loginid=m.loginid and ms.userid= m.loginid order by l.userid";
ds = objCon.SelectDataset(sqlStr, "0");
}
catch
{
}
return ds;
}
}
//*******************************************************************************
DESIGN PART..
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FakeMemberMark.aspx.cs" Inherits="FakeMemberMark" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head >
<script type="text/javascript">
function HighlightRow(chkB)
{
var IsChecked = chkB.checked;
if(IsChecked)
{
chkB.parentElement.parentElement.style.backgroundColor='black';
chkB.parentElement.parentElement.style.color='white';
}else
{
chkB.parentElement.parentElement.style.backgroundColor='white';
chkB.parentElement.parentElement.style.color='black';
}
}
function SelectAllCheckboxesSpecific(spanChk)
{
var IsChecked = spanChk.checked;
var Chk = spanChk;
Parent = document.getElementById('GridView1');
var items = Parent.getElementsByTagName('input');
for(i=0;i<items.length;i++)
{
if(items[i].id != Chk && items[i].type=="checkbox")
{
if(items[i].checked!= IsChecked)
{
items[i].click();
}
}
}
}
//*******************************************new one not using*******************
var TotalChkBx;
var Counter;
window.onload = function()
{
//Get total no. of CheckBoxes in side the GridView.
TotalChkBx = parseInt('<%= this.GridView1.Rows.Count %>');
//Get total no. of checked CheckBoxes in side the GridView.
Counter = 0;
}
function HeaderClick(CheckBox)
{
//Get target base & child control.
var TargetBaseControl = document.getElementById('<%= this.GridView1.ClientID %>');
var TargetChildControl = "chkBxSelect";
//Get all the control of the type INPUT in the base control.
var Inputs = TargetBaseControl.getElementsByTagName("input");
//Checked/Unchecked all the checkBoxes in side the GridView.
for(var n = 0; n < Inputs.length; ++n)
if(Inputs[n].type == 'checkbox' && Inputs[n].id.indexOf(TargetChildControl,0) >= 0)
Inputs[n].checked = CheckBox.checked;
//Reset Counter
Counter = CheckBox.checked ? TotalChkBx : 0;
}
function ChildClick(CheckBox, HCheckBox)
{
//get target base & child control.
var HeaderCheckBox = document.getElementById(HCheckBox);
//Modifiy Counter;
if(CheckBox.checked && Counter < TotalChkBx)
Counter++;
else if(Counter > 0)
Counter--;
//Change state of the header CheckBox.
if(Counter < TotalChkBx)
HeaderCheckBox.checked = false;
else if(Counter == TotalChkBx)
HeaderCheckBox.checked = true;
}
</script>
<title>Affiliser Admin � Fake Member Marking</title>
<link rel="stylesheet" type="text/css" href="StyleSheet.css" />
</head>
<body>
<div class="FormHeadingDiv"> Affiliser Admin � Fake Member Marking</div>
<div style="text-align:center;background-color:#E7DBD5">
<form id="form1" runat="server">
<div class="xLabelUserInfo"><asp:Label ID="Label2" runat="server" Text=""></asp:Label></div>
<div >
<div>
<asp:Label ID="lblcaption" runat="server" BackColor="Olive" Font-Bold="True" Font-Names="Arial" Font-Size="Medium" ForeColor="PaleGreen" Width="123px" ></asp:Label><br />
</div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<progresstemplate>
<strong>Please wait..Processing....</strong><br />
<img src="http://affiliser.com//images/site/ajax-loader.gif" />
</progresstemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<contenttemplate>
<div> <asp:Label ID="Label5" runat="server" ></asp:Label><br />
</div>
<div>
<asp:GridView ID="GridView1" CssClass="xGridViewPro" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#010101" BorderStyle="Groove" BorderWidth="1px" CellPadding="4" AllowPaging="True" ShowFooter="True" OnRowCommand="GridView1_RowCommand" OnRowCreated="GridView1_RowCreated" OnRowDataBound="GridView1_RowDataBound" OnPageIndexChanging="GridView1_PageIndexChanging">
<Columns>
<asp:BoundField DataField="userid" HeaderText="userid" Visible="true"/>
<asp:TemplateField HeaderText="userid" Visible="false">
<ItemTemplate>
<asp:Label ID="lbluserid" runat="server" Text='<%# Bind("userid") %>' ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="username">
<ItemTemplate>
<asp:Label ID="lblusername" runat="server" Text='<%# Bind("username") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="firstname">
<ItemTemplate>
<asp:Label ID="lblfirstname" runat="server" Text='<%# Bind("firstname") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="lastname">
<ItemTemplate>
<asp:Label ID="lblastname" runat="server" Text='<%# Bind("email") %>' ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Photo">
<ItemTemplate>
<asp:HyperLink ID="Hyperphotourl" runat="server" ImageUrl='<%#Bind("photourl")%>' NavigateUrl='<%#Bind("photourl")%>'>Photo</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ControlStyle-BackColor="AliceBlue" FooterStyle-BackColor="graytext" >
<HeaderTemplate>
<asp:CheckBox ID="chkAll" onclick="javascript:SelectAllCheckboxesSpecific(this);" runat="server" Text="Select" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox onclick="javascript:HighlightRow(this);" ID="chkBxSelect" runat="server" />
</ItemTemplate>
<FooterTemplate>
<asp:Button ID="BtnSET" runat="server" Text="SET" CommandName="SET" Height="33px" Width="99px" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="IsFake" Visible="false">
<ItemTemplate>
<asp:Label ID="lblIsFake" runat="server" Text='<%# Bind("IsFake") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="White" ForeColor="#330099" />
<RowStyle BackColor="White" ForeColor="#330099" />
<HeaderStyle BackColor="#F06300" Font-Bold="True" ForeColor="#FFFFCC" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
</div>
</contenttemplate>
</asp:UpdatePanel>
<br />
<asp:Button ID="btnSubmit" runat="server" Height="35px" OnClick="btnSubmit_Click" Text="Submit"
Width="99px" /><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</div>
</form>
</div>
</body>
</html>
Saturday, December 19, 2009
Some tips image url
bnrimg.InnerHtml = "<a href=" + ds.Tables[0].Rows[0][1].ToString() + " target=_blank><img width=468 height=60 border=0 src=" + ds.Tables[0].Rows[0].ItemArray[0].ToString() + " /></a>";
//Thumbnail
System.Web.UI.HtmlControls.HtmlGenericControl dynDiv = (System.Web.UI.HtmlControls.HtmlGenericControl)Parent.Page.FindControl("profImg");
dynDiv.InnerHtml = "";
System.Web.UI.WebControls.Label LabelParentfullname = (System.Web.UI.WebControls.Label)Parent.Page.FindControl("lblfullname");
LabelParentfullname.Text = fullNameN;
//Thumbnail
System.Web.UI.HtmlControls.HtmlGenericControl dynDiv = (System.Web.UI.HtmlControls.HtmlGenericControl)Parent.Page.FindControl("profImg");
dynDiv.InnerHtml = "";
System.Web.UI.WebControls.Label LabelParentfullname = (System.Web.UI.WebControls.Label)Parent.Page.FindControl("lblfullname");
LabelParentfullname.Text = fullNameN;
Subscribe to:
Posts (Atom)