|
I am working on this problem a couple of days, I did not get solution.
in my web page , there is a gridview with a checkbox templatefield
I need to know if checkbox is checked, I use following way, Even though I saw the checkbox is checked, I get checkbox.check is false.
<asp:gridview id="GridView1" runat="server" datakeynames="empid" cellpadding="4" forecolor="#333333" gridlines="None" width="335px">
<columns>
<asp:templatefield>
<headertemplate> <asp:checkbox id="chkall" runat="server">
<itemtemplate>
<asp:checkbox id="chk" runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
string EmpId="";
//bool chkBox=false ;
foreach (GridViewRow row in GridView1.Rows)
//for(int row=0;row<gridview1.rows.count;row++)
{
="" checkbox="" cb="((CheckBox)row.FindControl("chk"));
"
="" if="" (cb="" !="null" &&="" cb.checked)
="" if(cb.checked="=true)
" chkbox="true" ;
="" empid="GridView1.DataKeys[row.RowIndex].Value.ToString();
" label1="" .text="" +="string.Format(
" "this="" would="" have="" deleted="" {0}<br="">", EmpId);
}
}
|
|
|
|
|
|
<asp:gridview id="GridView1" runat="server" datakeynames="empid" cellpadding="4" forecolor="#333333" gridlines="None" width="335px">
<columns>
<asp:templatefield>
<headertemplate> <asp:checkbox id="chkall" runat="server">
<itemtemplate>
<asp:checkbox id="chk" runat="server">
<footerstyle backcolor="#5D7B9D" font-bold="True" forecolor="White">
<rowstyle backcolor="#F7F6F3" forecolor="#333333">
<editrowstyle backcolor="#999999">
<selectedrowstyle backcolor="#E2DED6" font-bold="True" forecolor="#333333">
<pagerstyle backcolor="#284775" forecolor="White" horizontalalign="Center">
<headerstyle backcolor="#5D7B9D" font-bold="True" forecolor="White">
<alternatingrowstyle backcolor="White" forecolor="#284775">
|
|
|
|
|
Check Ignore HTML tags in this message (good for code snippets) Check box and paste HTML code
Best Regard
Pathan
---------------------------------------------------
|
|
|
|
|
hai,
try this one,
CheckBox chkbox = new CheckBox();
foreach(DataGridItem item in gridsearch.Items )
{
chkbox=(CheckBox)item.FindControl("chkbox");
if(chkbox.Checked)
{
//if its true code here//
}
}
Regards
vidya
pain gives gain
|
|
|
|
|
Dear Developers,
I'm importing CSV file to sql DB using ASP.net. It works fine. But ,If a Cell contain a value like john,inc. CSV take it as two values as john and inc
But i want in a single value as john,inc .. How can i do thatThanks in Regards,
Prajin
|
|
|
|
|
For this kind of value you have to use ' or " to enclose the Value
Ex// 1,'john,store',aroda
Best Regards,
Chetan Patel
|
|
|
|
|
Hi Chetan,
This did not work when I read "1,'john,store',aroda" from file and split it on comma to convert to a datatable, "john" and "store" are coming in different columns. I want this in same column.
Regards,
Prajin
|
|
|
|
|
Can u please post the code??
|
|
|
|
|
try
{
memStream = new MemoryStream(fileImport.FileBytes);
reader = new StreamReader((Stream)memStream);
int nCurrPosition = 0;
int nNoOfCharactersToBeRead = Convert.ToInt32(reader.BaseStream.Length) - nCurrPosition;
szRawString = "";
if (nNoOfCharactersToBeRead >= 0)
{
reader.BaseStream.Seek(0, SeekOrigin.Begin);
char[] vBuffer = new char[nNoOfCharactersToBeRead];
reader.Read(vBuffer, 0, nNoOfCharactersToBeRead);
if (vBuffer.Length != 0)
{
szRawString = ReArrangeStringEx(vBuffer);
}
}
if (szRawString != "")
{
szRawString = szRawString.Replace("\r", "");
string[] rows = szRawString.Split("\n".ToCharArray());
for (int j = 0; j < rows.Length; j++)
{
string[] columns = rows[j].Split(',');
if (dtCustomer.Columns.Count == columns.Length)
{
dtCustomer.Rows.Add(columns);
}
}
}
reader.Close();
memStream.Close();
|
|
|
|
|
Well you're not operating on this as a CSV (which would honour the quotes as a text identifier) - you're simply splitting the string using comma:
string[] columns = rows[j].Split(',');
If you want to roll your own code to read from a CSV then you'll need to build something into this line above that honours quotes as a text identifier.
|
|
|
|
|
I suppose u first split your string by ' and then split it by comma. Hope it works.
|
|
|
|
|
for (int j = 0; j < rows.Length; j++)
{
string[] columns = rows[j].Split(',');
if (dtCustomer.Columns.Count == columns.Length)
{
dtCustomer.Rows.Add(columns);
}
}
change your code like this
arrTemp[]=rows[j].Split("'")
you get three parts
1,'abc,def',asd
as 1,
abc,def
,asd
now
add this like this
for (int j = 0; j < rows.Length; j++)
{
arrTemp[]=rows[j].Split("'")
dtCustomer.Rows.Add(arrTemp[0].subString(1,arrTemp[0].Length-1);
dtCustomer.Rows.Add(arrTemp[1]);
dtCustomer.Rows.Add(arrTemp[2].subString(2);
}
Best Regards,
Chetan Patel
|
|
|
|
|
Hi All,
I have a GridView in which all the column are template Column that contain textbox as a item Template. I have defined textChanged event for textboxes.
I have made these textbox as AutopostBack as true so that if I make any change in this textbox I can get that change in code behind file.(I wan to do with code behind file only no JavaScript)
Now if I edit any textbox which is inside the Gridview Problem lies here if I edit the textbox ,the textbox event for that textbox is called as many as time as there are number of rows in gridview and moreover it happen only when I edit the textbox for firsttime after that it execute only for only once .
So if someone has met with this problem pls do update me .
Thanks
Rahul
|
|
|
|
|
Check the URL can read some of the articles vert helpfull while working with gridview http://gridviewguy.com/CategoryDetails.aspx?categoryID=7[^]
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Sorry Guy.
You can not handle Textbox events.
Best Regards,
Chetan Patel
|
|
|
|
|
Hello everyone,
This is developed in .Net 2.0 (ASP .NET with VB .NET as code)
In a page, I have 9 fields for user to upload files. I have just encountered a situation where I choose a file for all the fields (that means 9 files), and when the total sum of file size (of the 9 files) exceeds a certain amount, the next page that I see after I click on submit is "Page cannot be displayed".
When I choose the 9 files with smaller size, the system works just fine.
Do you have any idea if there is such a limitation on the file size to be uploaded in a form? If there is, what is the size?
Appreciate your help.
Thanks,
Yenyen
|
|
|
|
|
That's becuase you are going beyond default maximum size that request can have you need to make it more in Web.config
httpRuntime maxRequestLength="100000" add this in system.web tag
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Dear All,
I have a gridview where first 2 columns are bound fields.
Next 3 columns have template fields with textboxes which are requiered to be filled by user.
i want if user does not provide any value, should be informed then and there through javascript.
I have written one which displays message but focus moves to next field.
I have given my code below.
Please help me.
Thanks;
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<title>Untitled Page
<asp:gridview id="GridView1" runat="server" autogeneratecolumns="False" width="552px" cellpadding="4" forecolor="#333333" gridlines="None">
<columns>
<asp:templatefield headertext="SUB_ID">
<itemtemplate>
<asp:textbox id="TextBox1" runat="server" text="<%# Bind("sub_ID") %>">
<asp:templatefield headertext="name">
<itemtemplate>
<asp:textbox id="TextBox2" runat="server" text="<%# Bind("sub_name") %>">
<asp:templatefield headertext="Marks">
<itemtemplate>
<asp:textbox id="TextBox3" runat="server">
<asp:templatefield headertext="Marks-II">
<itemtemplate>
<asp:textbox id="TextBox4" runat="server">
<asp:templatefield headertext="MARKS-III">
<itemtemplate>
<asp:textbox id="TextBox5" runat="server">
<footerstyle backcolor="#507CD1" font-bold="True" forecolor="White">
<rowstyle backcolor="#EFF3FB">
<editrowstyle backcolor="#2461BF">
<selectedrowstyle backcolor="#D1DDF1" font-bold="True" forecolor="#333333">
<pagerstyle backcolor="#2461BF" forecolor="White" horizontalalign="Center">
<headerstyle backcolor="#507CD1" font-bold="True" forecolor="White">
<alternatingrowstyle backcolor="White">
<asp:button id="Button1" runat="server" text="Button">
-----------------------------
var gridViewCtlId = '<%=gridview1.ClientID%>';
var gridViewCtl = null;
var curSelRow = null;
var curRowIdx = -1;
function getGridViewControl()
{
if (null == gridViewCtl)
{
gridViewCtl = document.getElementById(gridViewCtlId);
}
}
function onGridViewRowSelected(rowIdx)
{
var selRow = getSelectedRow(rowIdx);
if (null != selRow)
{
curSelRow = selRow;
var cellValue = getCellValue(rowIdx, 0);
alert(cellValue);
}
}
function getSelectedRow(rowIdx)
{
return getGridRow(rowIdx);
}
function getGridRow(rowIdx)
{
getGridViewControl();
if (null != gridViewCtl)
{
return gridViewCtl.rows[rowIdx];
}
return null;
}
function getGridColumn(rowIdx, colIdx)
{
var gridRow = getGridRow(rowIdx);
if (null != gridRow)
{
return gridRow.cells[colIdx];
}
return null;
}
function getCellValue(rowIdx, colIdx)
{
var gridCell = getGridColumn(rowIdx, colIdx);
switch(gridCell.childNodes.item(0).value)
{
case "":
gridCell.childNodes.item(0).focus();
alert("Please enter the value");
break;
return false;
default:
return true;
}
}
--------------------------------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
LoadGridData()
End If
For Each row As GridViewRow In GridView1.Rows
rowIndex = rowIndex + 1
For ctr = 0 To 4
CType(row.FindControl("Textbox" + (ctr + 1).ToString), TextBox).Attributes("onblur") = "javascript: return getCellValue(" + rowIndex.ToString() + "," + ctr.ToString() + ")"
Next
Next
End Sub
sanjay kumar samantaray
|
|
|
|
|
This is my code
Session["MySession"]="My Session Value";
In web.config
<sessionstate mode="SQLServer"
="" cookieless="true" regenerateexpiredsessionid="true" timeout="30" sqlconnectionstring="Data Source=MySqlServer;Integrated Security=SSPI;" statenetworktimeout="30">
In which table my session data will store in the MySqlServer database.
|
|
|
|
|
TempDB
Best Regards,
Chetan Patel
|
|
|
|
|
Hi,
I am new in asp.net2.0 ,I have create one project,
In project folder I don't have a bin folder and project source file,
how i create this files,
thanks
|
|
|
|
|
Right click the project you can see the bin menu under Add ASP.Net Folder. it will create a bin folder.
|
|
|
|
|
Thanks for your reply,
Bin folder create but there no project dll file.
Also how to create project source file
thanks
r
|
|
|
|
|
IF its Web aaplication dll wil not be created if you have class library in you application then dll will created of that application not of web application. Only you can have to precompile the web application
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|