| Back to Questions Page |
| |
| Question |
How to get the row index on checking a Checkbox in a ListView |
Rank |
Answer Posted By |
|
Question Submitted By :: San |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | 1.
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/5e6653e7-8503-44b8-ab0d-e0de7ace07f5
2.
http://social.msdn.microsoft.com/forums/en-US/wpf/thread/52e1fdd6-3841-4f47-955c-79c85b37ad43/
3.
http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/1c25c338-2b50-4c30-aac6-b3676700dff6
4.
http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.languages.csharp/2007-10/msg02293.html
5.
http://www.codeverge.net/ng.asp-net-forum.vs_2005_web_application_projects/how-to-get-row-id-with-html-checkbox-in-gridview
6.
http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/d8d8508c-5295-44bc-be76-0c9d25ebae8b
7.
http://stackoverflow.com/questions/1060864/c-listview-unable-to-check-a-checkbox-strange-problem
8.
http://www.c-sharpcorner.com/Forums/ShowMessages.aspx?ThreadID=7196  |
| San |
| |
| |
| Question |
how to convert Dataset to Object Array or list in c# .net |
Rank |
Answer Posted By |
|
Question Submitted By :: Kris |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | 1-->
http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/5b1c29e2-bf37-4dd2-be39-50d27abb188e
2-->
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/8d3834a8-2749-4bd6-a32b-f8a162a5b641
3-->
http://programming.top54u.com/post/ASP-Net-C-sharp-Convert-DataSet-to-ArrayList.aspx
4-->
http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/24b786da-fc87-4264-b934-5a0381ca6bdc  |
| Sona |
| |
| |
| Answer | http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/24b786da-fc87-4264-b934-5a0381ca6bdc
this one works fine.
DataTable dt = ds.Tables[0];
List<Employee> emp = new List<Employee>();
foreach (DataRow dr in dt.Rows)
{
Employee em = new Employee();
em.Name = dr["Name"].ToString();
em.age = Convert.ToInt32(dr["Age"]);
em.Salary = Convert.ToInt32(dr["Salary"]);
emp.Add(em);
}  |
| San |
| |
| |
|
|
| |
| Answer | DataTable dt = ds.Tables[0];
List<Employee> emp = new List<Employee>();
foreach (DataRow dr in dt.Rows)
{
Employee em = new Employee();
em.Name = dr["Name"].ToString();
em.age = Convert.ToInt32(dr["Age"]);
em.Salary = Convert.ToInt32(dr["Salary"]);
emp.Add(em);
}  |
| Mohan |
| |
| |
| Question |
how to design a ListView control? |
Rank |
Answer Posted By |
|
Question Submitted By :: Sona |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | </tr> <asp:ListView ID="lstBank" runat="server"
OnItemCommand="lstBank_ItemCommand" >
<LayoutTemplate>
<table border="0"
cellpadding="4" class="tblGrid tblAccount">
<tr>
<th
style="text-align:center; width: 90px">
<asp:Label ID="lblVoucherNo" Text="Voucher No"
runat="server"></asp:Label>
</th>
<th
style="text-align:left; width: 90px">
<asp:Label ID="lblDate" Text="Date"
runat="server"></asp:Label>
</th>
<th
style="text-align:left; width: 90px">
<asp:Label ID="lblChequeNo" Text="Cheque No"
runat="server"></asp:Label>
</th>
<th
style="text-align:left; width: 90px">
<asp:Label ID="lblChequeDate" Text="Cheque Date"
runat="server"></asp:Label>
</th>
<th
style="text-align:left; width: 90px">
<asp:Label ID="lblAmount" Text="Amount"
runat="server"></asp:Label>
</th>
<th
style="text-align:left; width: 90px">
<asp:Label ID="lblPartyName" Text="Party Name"
runat="server"></asp:Label>
</th>
<th
style="text-align:left; width: 90px">
<asp:Label ID="lblDate" Text="Date"
runat="server"></asp:Label>
</th>
<th
style="text-align:center; width: 50px">
<asp:Label ID="lblCheck" Text="Check"
runat="server"></asp:Label>
</th>
</tr>
<asp:PlaceHolder runat="server"
ID="itemPlaceholder"></asp:PlaceHolder>
<tr
class="gridOddRow gridOddRowListUser">
<td
colspan="10" class="noBrdrBtm noBrdrRght">
<table
class="tblTotalRecords">
<tr
class="removeHoverColor">
<td valign="top" align="left">
<div style="text-align: left; padding-top: 4px;
vertical-align: text-bottom">
Total Records:
<asp:Label ID="lblTotalRecords" runat="server"
Text="1"></asp:Label>
</div>
</td>
<td valign="middle">
<div style="text-align: center;">
Page Size:
<asp:DropDownList AutoPostBack="true"
OnSelectedIndexChanged="ddlPagingSize_OnSelectedIndexChanged
"
CssClass="PagingDropDownStyle"
ID="ddlPagingSize" name="ddlPagingSize" runat="server">
</asp:DropDownList>
</div>
</td>
<td align="center" valign="middle" colspan="10">
<div style="text-align: center;">
<asp:LinkButton ID="lnkPrev" CommandName="Prev"
ToolTip="Previous" runat="server"> << </asp:LinkButton>
Page
<asp:TextBox OnKeyPress="return DoPagingOnEnter();"
runat="server" Width="18px" Height="12px"
Style="text-align: center; font-family: Arial;
font-size: 11px;" Text="1" ID="txtPage"></asp:TextBox>
of
<asp:Label ID="lblCount"
runat="server">1</asp:Label>
page(s)
<asp:LinkButton ID="lnkNext" CommandName="Next"
ToolTip="Next" runat="server"> >> </asp:LinkButton>
</div>
</td>
</table>
</td>
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr id="idRows"
onclick="return ChangeRowColor(this);" class="<%#
Container.DisplayIndex % 2 ==
0 ? "gridOddRow" : "gridEvenRow" %>" >
<td
style="display:none" >
<asp:Label
runat="server" Text='<%# Eval("VoucherId")%>'
ID="lblVoucherId"></asp:Label>
</td>
<td>
<asp:Label
runat="server" Text='<%# Eval("VoucherNumber")%>'
ID="lblVoucherNo"></asp:Label>
</td>
<td>
<asp:Label
runat="server" Text='<%# Eval
("VoucherDate","{0:dd/MM/yyyy}")%>'
ID="lblDate"></asp:Label>
</td>
<td>
<asp:Label
runat="server" Text='<%# Eval("ChequeDDNo")%>' ToolTip='<%#
Eval("ChequeDDNo")%>'
ID="lblChequeNo"></asp:Label>
</td>
<td >
<asp:Label
runat="server" Text='<%# Eval
("ChequeDDDate","{0:dd/MM/yyyy}")%>'
ID="lblChequeDate"></asp:Label>
</td>
<td>
<asp:Label
runat="server" Text='<%# Eval("Amount")%>'
ID="lblAmount"></asp:Label>
</td>
<td >
<asp:Label
runat="server" Text='<%# Eval("PartyName")%>'
ID="lblPartyName"></asp:Label>
</td>
<td
>
<asp:TextBox
runat="server" ID="txtDate" Text='<%# Eval
("ReconciledDate","{0:dd/MM/yyyy}")%>' class="txtNormal
CustomWidth" onkeypress="Date_Only();" > </asp:TextBox>
<ajax:CalendarExtender ID="calDate"
PopupPosition="BottomRight" Format="dd/MM/yyyy"
TargetControlID="txtDate" runat="server">
</ajax:CalendarExtender>
</td>
<td >
<asp:CheckBox runat="server" ID="chkRec" value='< %# Eval
("VoucherNumber")%>' OnCheckedChanged="chkRec_checked"
AutoPostBack="true" /> <%--onMouseDown=<%#"return TestCheck
('"+ Eval("Amount") +"',this);"%>--%>
</td>
</tr>
</ItemTemplate>
<EmptyDataTemplate>
<table border="0"
cellpadding="4" class="tblGrid tblAccount">
<tr>
<th
style="display:
none">
<asp:Label ID="lblVoucherId" Text="Voucher Id"
runat="server"></asp:Label>
</th>
<th
style="padding-left: 4px; width:
100px">
Voucher
No
<th
style="padding-left: 4px; width:
150px">
<asp:Label ID="lblCurrency" Text="Voucher Date"
runat="server"></asp:Label>
</th>
<th
style="text-align:right; width: 100px">
<asp:Label ID="lblChequeNo" Text="Cheque No"
runat="server"></asp:Label>
</th>
<th
style="text-align:right; width: 110px">
<asp:Label ID="lblChequeDate" Text="Cheque Date"
runat="server"></asp:Label>
</th>
</th>
<th
style="padding-left: 4px; width:
180px">
<asp:Label ID="lblAmount" Text="Amount"
runat="server"></asp:Label>
</th>
<th
style="padding-left: 4px; width:
180px">
<asp:Label ID="lblPartyName" Text="Party"
runat="server"></asp:Label>
</th>
<th
style="padding-left: 4px; width:
180px">
<asp:Label ID="lblDate" Text="Reconcile Date"
runat="server"></asp:Label>
</th>
<th
style="padding-left: 4px; width:
180px">
<asp:Label ID="lblCheck" Text="Reconcile"
runat="server"></asp:Label>
</th>
</tr>
<tr>
<td
class="gridOddRow" colspan="10">
<center>
<b>No records found.</b>
</center>
</td>
</tr>
</table>
</EmptyDataTemplate>
</asp:ListView>  |
| Kris |
| |
| |
| Question |
hold checkbox values |
Rank |
Answer Posted By |
|
Question Submitted By :: Guest |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | private void CheckChkBoxStatusHold()
{
ArrayList objChkBoxID = new ArrayList();
if (Cache[(Session["Userid"]
+ "BankReconChkBoxID")] != null)
{
objChkBoxID=(ArrayList)Cache[(Session
["Userid"] + "BankReconChkBoxID")];
}
for (int i = 0; i < CurPageCnt; i++)
{
if (intCheckSave == 1)
{
if (((CheckBox)
lstBankReconcilation.Items[i].FindControl
("chkReconcile")).Checked == true)
{
objChkBoxID.Add(((Label)
lstBankReconcilation.Items[i].FindControl
("lblVoucherId")).Text);
DateTime dtReconDate =
Convert.ToDateTime((((TextBox)lstBankReconcilation.Items
[i].FindControl("txtReconcileDate")).Text), new CultureInfo
("hi-IN"));
objChkBoxID.Add(dtReconDate.ToString
("dd-MMM-yyyy"));
}
}
else if (intCheckSave == 0)
{
if (((CheckBox)
lstBankReconcilation.Items[i].FindControl
("chkReconcile")).Checked == false)
{
objChkBoxID.Add(((Label)
lstBankReconcilation.Items[i].FindControl
("lblVoucherId")).Text);
DateTime dtReconDate =
Convert.ToDateTime((((TextBox)lstBankReconcilation.Items
[i].FindControl("txtReconcileDate")).Text), new CultureInfo
("hi-IN"));
objChkBoxID.Add(dtReconDate.ToString
("dd-MMM-yyyy"));
}
}
}
Cache.Remove((Session["Userid"]
+ "BankReconChkBoxID"));
Cache[(Session["Userid"]
+ "BankReconChkBoxID")] = objChkBoxID;
}  |
| Sona |
| |
| |
| Answer | this one fr retrieving
private void CheckChkBoxStatusRetrieve()
{
ArrayList objChkBoxRetrieve=new ArrayList();
if (Cache[(Session["Userid"]
+ "BankReconChkBoxID")] != null)
{
objChkBoxRetrieve=(ArrayList)Cache[(Session
["Userid"] + "BankReconChkBoxID")];
for (int j = 0; j <
objChkBoxRetrieve.Count; j++)
{
for (int i = 0; i < CurPageCnt; i++)
{
if (objChkBoxRetrieve[j].ToString()
== ((Label)lstBankReconcilation.Items[i].FindControl
("lblVoucherId")).Text)//lblVoucherNo
{
((CheckBox)
lstBankReconcilation.Items[i].FindControl
("chkReconcile")).Checked = true;
((TextBox)
lstBankReconcilation.Items[i].FindControl
("txtReconcileDate")).Text = DateTime.Now.ToString
("dd/MM/yyyy");
}
}
}
}
}  |
| Sona |
| |
| |
| Answer | private List<int> IDs
{
get
{
if (this.ViewState["IDs"] == null)
{
this.ViewState["IDs"] = new List<int>();
}
return (List<int>)this.ViewState["IDs"];
}
}
protected void AddRowstoIDList()
{
int checkAction = 0;
foreach (ListViewDataItem lvi in lvUsersinGroup.Items)
{
CheckBox chkSelect =
(CheckBox)lvi.FindControl("chkSelect");
if ((((chkSelect) != null)))
{
int ID =
Convert.ToInt32(lvUsersinGroup.DataKeys[lvi.DisplayIndex].Value);
if ((chkSelect.Checked &&
!this.IDs.Contains(ID)))
{
this.IDs.Add(ID);
checkAction += 1;
}
else if ((!chkSelect.Checked &&
this.IDs.Contains(ID)))
{
this.IDs.Remove(ID);
}
}
}
}  |
| Kris |
| |
| |
| Answer | 1]
http://blog.evonet.com.au/post/2008/08/Maintaining-Checkbox-State-in-a-Listview.aspx
2]
http://demo.evonet.com.au/MaintainingListviewCheckboxState.aspx
3]
http://www.codeproject.com/KB/webforms/States_of_CheckBoxes.aspx
4] http://forums.asp.net/t/1282544.aspx
5]
http://www.ilearnttoday.com/index.php/c-aspnet-gridview-how-to-keep-modified-data-of-template-fields-when-paging-is-enabled/comment-page-1  |
| Sona |
| |
| |
| Question |
working with fileUpload ? |
Rank |
Answer Posted By |
|
Question Submitted By :: Guest |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | <asp:FileUpload ID="FileUpload1" runat="server"
onchange="change(this);" />
//js
function change(fileupload) {
if (fileupload.value.indexOf('jpg') == '-1') {
document.getElementById('TextBox1').value =
'Nopicture';
alert('Select *.jpg file only');
}
if (fileupload.value.indexOf('jpg') != '-1') {
document.getElementById('TextBox1').value =
'haspicture';
}
}
function changevalue() {
if
(document.getElementById('FileUpload1').value == '') {
alert('Please select a file');
return false;
}
if
(document.getElementById('FileUpload1').value !='')
{
if
(document.getElementById('FileUpload1').value.indexOf('jpg')
== '-1') {
alert('upload *.jpg images only');
return false;
}
}
//code behind
protected void btnUpload_Click(object sender, EventArgs e)
{
if (btnUpload.Text == "Upload")
{
if (FileUpload1.HasFile)
{
Stream imgStream =
FileUpload1.PostedFile.InputStream;
int imgLen =
FileUpload1.PostedFile.ContentLength;
byte[] img = new byte[imgLen];
int n = imgStream.Read(img, 0, imgLen);
Session["Picture"] = img;
lblMessage.Text = "Attached";
btnUpload.Text = "Remove";
}
else
{
Session["Picture"] = null;
}
}
else
{
Session["Picture"] = null;
btnUpload.Text = "Upload";
lblMessage.Text = "Removed";
}
}  |
| Guest |
| |
| |
| Question |
how to upload an excel in c# ASP.Net? |
Rank |
Answer Posted By |
|
Question Submitted By :: Kris |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | protected void btnUpload_Click(object sender, EventArgs e)
{
if (fuUpload.HasFile)
{
string filename = fuUpload.PostedFile.FileName;
string strConn;
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;"
+"Data Source="+ filename +";" +"Extended Properties=Excel
8.0;";
OleDbConnection con = new OleDbConnection(strConn);
con.Open();
OleDbCommand cmd = new OleDbCommand("select *
from [Sheet1$]",con);
OleDbDataAdapter dad = new OleDbDataAdapter();
dad.SelectCommand = cmd;
DataSet ds= new DataSet();
dad.Fill(ds);
DataGrid1.DataSource = ds.Tables[0].DefaultView;
DataGrid1.DataBind();
con.Close();
}
}  |
| Kris |
| |
| |
| Answer | var uploadPath = Server.MapPath("xx/fdd") + @"\" +
if (!Directory.Exists(uploadPath))
{
Directory.CreateDirectory(uploadPath);
}
.
if (flupload.PostedFile.FileName.Length > 0)
{
if (flupload.PostedFile.ContentType !
= "application/octet-stream") // text/plain
{
ShowMessage("' Error'");
return;
}
if (GetFileType
(flupload.PostedFile.FileName) != ".xls")
{
ShowMessage("'Error'");
return;
}
//Upload the selected diary file for
furhter processing.
varFileName = Path.GetFileName
(flupload.PostedFile.FileName);
varFileName = uploadPath + @"\" +
varFileName;
flupload.SaveAs(varFileName);
//Get File type - only csv file is considered here..
private string GetFileType(string fileName)
{
return fileName.Substring(fileName.LastIndexOf
("."), fileName.Length - fileName.LastIndexOf("."));
}
public DataTable ReadExcelIntoDataTable(string filename,
string SheetName)
{
string connectionString
= "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" +
filename + ";" +
"Extended
Properties=Excel 8.0;";
OleDbConnection objConn = new OleDbConnection
(connectionString);
objConn.Open();
OleDbCommand ObjCommand = new OleDbCommand
("SELECT * FROM [" + SheetName + "$]", objConn);
OleDbDataAdapter objAdp = new OleDbDataAdapter
();
objAdp.SelectCommand = ObjCommand;
DataSet excelSheetDataSet = new DataSet();
objAdp.Fill(excelSheetDataSet);
DataTable excelSheetTable =
excelSheetDataSet.Tables[0];
objConn.Close();
return excelSheetTable;
}
private string ReadImportedDataFromFile(string uploadPath)
{
string[] StrSheetNames = GetExcelSheetNames
(uploadPath);
DataTable excelSheetTable =
ReadExcelIntoDataTable(uploadPath, StrSheetNames[5]);
StringBuilder sbExcel= new StringBuilder();
int rowCount = 0, colCount = 0;
sbExcel.AppendFormat("<{0}>", "home");
foreach (DataRow dr in excelSheetTable.Rows)
{
if (rowCount >= 1)
{
sbExcel.AppendFormat("<{0}>", "Table");
foreach (DataColumn dc in
excelSheetTable.Columns)
{
if (dr[dc].ToString().Trim
().Length != 0)
{
if (colCount > 1)
{
sbExcel.AppendFormat
("<EmpCode>{0}</EmpCode>", dr[0].ToString().Trim());
sbExcel.AppendFormat
("<SalHeadId>{0}</SalHeadId>", dc.ColumnName.Trim());
//sbExcel.AppendFormat("<"
+ dc.ColumnName.Trim() + ">{0}</" + dc.ColumnName.Trim()
+ ">", dr[dc].ToString());
sbExcel.AppendFormat("<Rate>
{0}</Rate>", dr[dc].ToString());
}
//else
//{
// //string strFormat =
(colCount == 0 ? "<EmpCode>{0}</EmpCode>" : "<EmpName>{0}
</EmpName>");
// //sbExcel.AppendFormat
(strFormat,dr[dc].ToString().Trim());
//}
colCount++;
}
}
sbExcel.AppendFormat("</{0}>", "Table");
colCount = 0;
}
rowCount++;
}
sbExcel.AppendFormat("</{0}>", "home");
}  |
| Sona |
| |
| |
| Question |
Data Reader Vs DataSet |
Rank |
Answer Posted By |
|
Question Submitted By :: Guest |
| This Interview Question Asked @ TCS |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | data reader reads data and store it in table.
while dataset contains one or more datatable within itself.
datasets are connection less while datareader required
connection to read data.  |
| Gajendra |
| |
| |
| Question |
what is the value that reside in a hidden field when no
value is assigned to it?how it can be used in a if
statement?? |
Rank |
Answer Posted By |
|
Question Submitted By :: Prakash Kuttappan |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | If No value assigned to a hidden field then it contains
String.Empty value.
Habling empty value:
<%@ Page Language="VB" AutoEventWireup="true"
CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Demo</title>
</head>
<body>
<form id="form1" runat="server">
<asp:HiddenField ID="hndField" runat="server" />
</form>
</body>
</html>
Code behind...
Protected Sub Page_Load(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Me.Load
If hndField.Value <> String.Empty Then
do......
End If
End Sub  |
| Rupinder |
| |
| |
| Question |
how to upload a photo? i need to use it in a matrimonial
applicaton... |
Rank |
Answer Posted By |
|
Question Submitted By :: Prakash Kuttappan |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Well if you are working with any Web Server technology like PHP and MYSql.. for your matrimonial application then you can store the image in SQL database with the type BLOB. There are many sites with examples to explain hw u can store..  |
| Rayabhagi Srikanth |
| |
| |
| Question |
What do you create for easier access of data? |
Rank |
Answer Posted By |
|
Question Submitted By :: Guest |
| This Interview Question Asked @ NIIT |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | To Connect With SQL-Server & Access Data  |
| Parmod Malik |
| |
| |
| Answer | We can create a Data Access Layer to achieve the same .
Microsoft provides Enterprise library where we can find the Data Access Module and then use it for easy access of data from any database.  |
| Kunal Gandhi |
| |
| |
|
| |
|
Back to Questions Page |