|
Create a new datatable as
Datatable dt=new Datatable();
whatever columns u would like to insert add them.
if(dt.columns["a"]==null)
dt.columns.add(a);
if(dt.columns["b"]==null)
dt.columns.add(b);
if(dt.columns["c"]==null)
dt.columns.add(c);
DataRow dr = dt.NewRow();
dt.Rows.Add(dr);
dt.AcceptChanges();
nextadd the values into datatable as
dt.rows[0]["a"]=txtbox1.text;
dt.rows[0]["b"]=txtbox2.text;
dt.rows[0]["c"]=txtbox3.text;
|
|
|
|
|
thank you sir/mam, i didnt know how to express my thanks... this is my first time using datatable... and almost all you guys here in forum are really kind and helpful... highly appreciated... thank you very much
start a new beginning in every ending; thats what life for......
|
|
|
|
|
Welcome moomoooomoo..............
Go ahead............
|
|
|
|
|
Hai friends,
I need some information about editable gridview, Please provide.
My question is
i am sending text into one field of database with comma(,) seperated.
I want to retrive that field into editable gridview with different rows each comma seperated word.
i need a editable gridview without showing edit button in asp.net.
Thanking You,
Harinath
|
|
|
|
|
|
Hai
Thanks for providing your suggesion
bye
|
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<style type="text/css">
.style1
{
width: 119%;
}
.style2
{
width: 119%;
height: 16px;
}
.style14
{
width: 164px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<table border="0" width="100%" >
<tr>
<td width="100%" height="50">
<table height="50px" style="width: 100%">
</table>
</td>
</tr>
<tr>
<td>
<table bgcolor="#666666" width="100%">
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Registrant Details"
ForeColor="White"></asp:Label>
</td>
</tr>
<tr>
<td bgcolor="White" height="20">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width=100% align="right" style="width: 210px">
<tr align="right" >
<td class="style1" width="100%" align="left">
<asp:Label ID="Label2" runat="server" Text="Registry no"></asp:Label>
</td>
</tr>
<tr align="right">
<td class="style1" align="left">
<asp:Label ID="lblRegNo" runat="server" Text="40013242424" Font-Size="Smaller"></asp:Label>
</td>
</tr>
<tr align="right">
<td class="style1" width="100%" align="left">
<asp:Label ID="Label4" runat="server" Text="Event Date"></asp:Label>
</td>
</tr>
<tr align="right">
<td class="style2" width="100%" align="left">
<asp:Label ID="Label5" runat="server" Text="08/13/2016" Font-Size="Smaller"></asp:Label>
</td>
</tr>
<tr align="right">
<td class="style1" width="100%" align="left">
<asp:Label ID="Label6" runat="server" Text="Pickup Store "></asp:Label>
</td>
</tr>
<tr align="right">
<td class="style2" width="100%" align="left">
<asp:Label ID="Label7" runat="server" Text="St. Albert Centre" Font-Size="Smaller"></asp:Label>
</td>
</tr>
<tr align="right">
<td class="style2" width="100%" align="left">
<asp:Label ID="Label8" runat="server" Text="(000)000-0000" Font-Size="Smaller"></asp:Label>
</td>
</tr>
</table>
</td>
</tr>
<%--for grid--%>
<tr>
<td align="center">
<asp:GridView ID="grdOrders" runat="server" AutoGenerateColumns="false"
Width="1112px" HeaderStyle-BackColor=#CCCCCC ShowFooter="true"
AllowPaging="true" PageSize="5" onrowdatabound="GridView1_RowDataBound" >
<Columns>
<asp:BoundField HeaderText="Qty" DataField="Quantity" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="10" />
<asp:TemplateField HeaderText="Qty Req'd" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="20" >
<ItemTemplate>
<asp:Label ID="lblQtyRecvd" runat="server" Text='<%#Eval("QuantityRecieved") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Qty Rec'd" DataField="QuantityRequired" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="20"/>
<asp:BoundField HeaderText="Description" DataField="SkuName" ItemStyle-HorizontalAlign="left" HeaderStyle-Width="50" />
<asp:TemplateField HeaderText="Price" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="20" >
<ItemTemplate>
<asp:Label ID="lblDollar" runat="server" Text="$" />
<asp:Label ID="lblPrice" runat="server" Text='<%# (Eval("UnitPrice","{0 ,0.00}")) %>' />
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lbltxtTotal" runat="server" Text="Sub Total" Font-Bold="True" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Amount" HeaderStyle-Width="15" ItemStyle-HorizontalAlign="center">
<ItemTemplate >
<asp:Label ID="lblDollar1" runat="server" Text="$" />
<asp:Label ID="lblTotal" runat="server" Text='<%#String.Format("{0:n2}", Convert.ToDouble(Eval("UnitPrice")) * Convert.ToInt64(Eval("Quantity")))%>' />
</ItemTemplate>
<ItemStyle HorizontalAlign="Right" />
<FooterStyle HorizontalAlign="Right" />
<FooterTemplate>
<asp:Label ID="lblDollar1" runat="server" Text="$" Font-Bold="True" />
<asp:Label ID="lbltxtTotalPrice" runat="server" Font-Bold="True" />
</FooterTemplate>
</asp:TemplateField>
<%-- <asp:BoundField HeaderText="Price" DataField="price" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="20" FooterText="Total Price:"/>
<asp:BoundField HeaderText="total" DataField="total" ItemStyle-HorizontalAlign="left" HeaderStyle-Width="50" }" />--%>
</Columns>
</asp:GridView>
</td>
</tr>
<%-- <asp:BoundField HeaderText="Price" DataField="price" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="20" FooterText="Total Price:"/>
<asp:BoundField HeaderText="total" DataField="total" ItemStyle-HorizontalAlign="left" HeaderStyle-Width="50" }" />--%> <%--for grid--%><%--last--%>
<tr>
<td width="100%" height="20">
<table height="20px" border="1" align="center" width="1112px">
<tr align="right">
<td align=center class="style14">
<asp:Button ID="btnEmptybag" runat="server" Text="Empty Bag" Height="23px"
Width="95px" />
</td>
<td align="left"
style="font-family: Arial, Helvetica, sans-serif; font-size: small">
when applicable,special promotions and other discounts will be applied to the price(s) when your credit card is charged
</td>
</tr>
</table>
</td>
</tr>
<%-- table ag--%>
<tr>
<td width="100%" height="20">
<table height="50px" border="0" align="center" width="1112px">
<tr align="left">
<td align="left"
style="font-family: Arial, Helvetica, sans-serif; font-size: small">
</td>
<td align=center class="style14">
<asp:Button ID="btnShopping" runat="server" Text="<< Continue Shopping" Height="23px"
Width="145px" />
</td>
</tr>
</table>
</td>
</tr>
<%-- for continue to shopping--%>
</table>
</form>
</body>
</html>
-- modified 19-Sep-13 10:29am.
|
|
|
|
|
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="assignment._Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
var TotalChkBx;
var Counter;
window.onload = function () {
TotalChkBx = parseInt('<%= this.grdEmployees.Rows.Count %>');
Counter = 0;
}
function HeaderClick(CheckBox) {
var TargetBaseControl =
document.getElementById('<%= this.grdEmployees.ClientID %>');
var TargetChildControl = "chkBxSelect";
var Inputs = TargetBaseControl.getElementsByTagName("input");
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 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;
}
function isDelete() {
return confirm("Do you want to delete this row ?");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<%--for grid--%>
<%-- <asp:boundfield headertext="Price" datafield="price" itemstyle-horizontalalign="Center" headerstyle-width="20" footertext="Total Price:">
<asp:boundfield headertext="total" datafield="total" itemstyle-horizontalalign="left" headerstyle-width="50" }"="">--%><%-- <asp:boundfield headertext="Price" datafield="price" itemstyle-horizontalalign="Center" headerstyle-width="20" footertext="Total Price:">
<asp:boundfield headertext="total" datafield="total" itemstyle-horizontalalign="left" headerstyle-width="50" }"="">--%><%-- <asp:boundfield headertext="Price" datafield="price" itemstyle-horizontalalign="Center" headerstyle-width="20" footertext="Total Price:">
<asp:boundfield headertext="total" datafield="total" itemstyle-horizontalalign="left" headerstyle-width="50" }"="">--%>
<%--for grid--%>
<%--last--%>
<asp:gridview id="grdEmployees" runat="server" autogeneratecolumns="false" width="1112px"
="" headerstyle-backcolor="#CCCCCC" showfooter="true" allowpaging="true" pagesize="5" onrowcommand="grdEmployees_RowCommand" onselectedindexchanged="grdEmployees_SelectedIndexChanged" onrowdatabound="grdEmployees_RowDataBound" onrowdeleting="grdEmployees_RowDeleting">
<columns>
<asp:templatefield headertext="Select">
<itemtemplate>
<asp:checkbox id="chkBxSelect" runat="server">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="50px" />
<itemstyle horizontalalign="Center" verticalalign="Middle" width="50px">
<HeaderTemplate>
<asp:checkbox id="chkBxHeader" onclick="javascript:HeaderClick(this);" runat="server">
</HeaderTemplate>
<asp:templatefield headertext="Employee Id" itemstyle-horizontalalign="Center" headerstyle-width="40">
<itemtemplate>
<asp:label id="lblEmpId" runat="server" text="<%#Eval("EmpId") %>">
<HeaderStyle Width="40px"></HeaderStyle>
<itemstyle horizontalalign="Center">
<asp:templatefield headertext="Name" itemstyle-horizontalalign="Center" headerstyle-width="40">
<itemtemplate>
<asp:label id="lblEmpName" runat="server" text="<%#Eval("EmpName") %>">
<HeaderStyle Width="40px"></HeaderStyle>
<itemstyle horizontalalign="Center">
<asp:boundfield headertext="Account" datafield="Account" itemstyle-horizontalalign="Center"
="" headerstyle-width="20">
<HeaderStyle Width="20px"></HeaderStyle>
<itemstyle horizontalalign="Center">
<asp:boundfield headertext="Email" datafield="email" itemstyle-horizontalalign="Center"
="" headerstyle-width="20">
<HeaderStyle Width="20px"></HeaderStyle>
<itemstyle horizontalalign="Center">
<asp:templatefield headertext="Contact No" itemstyle-horizontalalign="Center" headerstyle-width="50">
<itemtemplate>
<asp:textbox id="txtContactNo" runat="server" text="<%#Eval("ContactNo") %>">
<HeaderStyle Width="50px"></HeaderStyle>
<itemstyle horizontalalign="Center">
<asp:templatefield headertext="Experience" itemstyle-horizontalalign="Center" headerstyle-width="10">
<itemtemplate>
<asp:textbox id="txtExp" runat="server" text="<%#Eval("Experience") %>">
<HeaderStyle Width="10px"></HeaderStyle>
<itemstyle horizontalalign="Center">
<asp:templatefield headertext="Skill" itemstyle-horizontalalign="Center" headerstyle-width="20">
<itemtemplate>
<asp:textbox id="txtSkill" runat="server" text="<%#Eval("Skill") %>">
<HeaderStyle Width="20px"></HeaderStyle>
<itemstyle horizontalalign="Center">
<%-- Adding button to gridview --%>
<asp:templatefield headertext="Delete">
<itemtemplate>
<asp:button id="BtnDelete" commandname="dele" runat="server" text="Delete" commandargument="<%# Eval("EmpId") %>" oonclientclick="isDelete()"
="" onclick="BtnDelete_Click">
<%-- <asp:boundfield headertext="Price" datafield="price" itemstyle-horizontalalign="Center" headerstyle-width="20" footertext="Total Price:">
<asp:boundfield headertext="total" datafield="total" itemstyle-horizontalalign="left" headerstyle-width="50" }"="">--%>
<HeaderStyle BackColor="#CC99FF"></HeaderStyle>
|
|
<asp:button id="btnUpdate" runat="server" onclick="btnUpdate_Click" text="Update">
<asp:label id="Label1" runat="server" text="Label">
|
|
|
</form>
</body>
</html>
|
|
|
|
|
public partial class _Default : System.Web.UI.Page
{
StringBuilder StrBuilder;
ClsHBC_Bl ObjHbcBL;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ObjHbcBL = new ClsHBC_Bl();
DataTable dt = new DataTable();
dt = ObjHbcBL.GetEmployees_BL();
ViewState["dt"] = dt;
grdEmployees.DataSource = dt;
grdEmployees.DataBind();
}
}
protected void BindGrid()
{
grdEmployees.DataSource =(DataTable) ViewState["dt"] ;
grdEmployees.DataBind();
}
protected void BtnDelete_Click(object sender, EventArgs e)
{
GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
Label1.Text = "hi";
}
protected void grdEmployees_RowCommand(object sender, GridViewCommandEventArgs e)
{
}
protected void grdEmployees_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void Button_click_event(Object sender, EventArgs e)
{
Label1.Text = "Hello";
}
protected void grdEmployees_RowDataBound(object sender, GridViewRowEventArgs e)
{
}
protected void grdEmployees_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int cEmployeeID = (int)grdEmployees.DataKeys[e.RowIndex].Value;
ObjHbcBL.DeleteEmployee_BL(cEmployeeID);
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
StrBuilder = new StringBuilder(string.Empty);
StringWriter stringWriter = new StringWriter(StrBuilder);
CheckBox CC;
DataSet ds = new DataSet();
DataTable dt = new DataTable("toUpdate");
dt.Columns.Add("EmpId", typeof(int));
dt.Columns.Add("ContactNo", typeof(String));
dt.Columns.Add("Experience", typeof(String));
dt.Columns.Add("Skill", typeof(String));
ds.Tables.Add(dt);
for (byte i = 0; i <= grdEmployees.Rows.Count-1; i++)
{
CC = (CheckBox)grdEmployees.Rows[i].FindControl("chkBxSelect");
if (CC.Checked)
{
DataRow r;
r = ds.Tables["toUpdate"].NewRow();
r["EmpId"] = int.Parse((grdEmployees.Rows[i].Cells[1].FindControl("lblEmpId") as Label).Text);
r["ContactNo"] = (grdEmployees.Rows[i].Cells[5].FindControl("txtContactNo") as TextBox).Text;
r["Experience"] = int.Parse((grdEmployees.Rows[i].Cells[6].FindControl("txtExp") as TextBox).Text);
r["Skill"] = (grdEmployees.Rows[i].Cells[7].FindControl("txtSkill") as TextBox).Text;
ds.Tables["toUpdate"].Rows.Add(r);
}
DataTable dtnew = ds.Tables["toUpdate"];
dtnew.WriteXml(stringWriter, XmlWriteMode.IgnoreSchema);
StrBuilder.Append(stringWriter);
}
}
}
|
|
|
|
|
hari4ur wrote: I want to retrive that field into editable gridview with different rows each comma seperated word.
You have to do manually.
hari4ur wrote: i need a editable gridview without showing edit button in asp.net
You can trigger the EditCommand using the JavaScript on the click of each row.
|
|
|
|
|
Can we add our own expression in regular expression validtor?
|
|
|
|
|
Yes.
For more Details
Clickety[^]
Regards,
Satips.
|
|
|
|
|
I am having very very strange problems woth VS.NET, I am opening toolbox option having all the web form components but the pin for enabling or disabling auto hide properties just not seem to appear opposit to "x"(cross sign),I want to enable the auto hide property of my toolbox but without the pin sign it is not possible, any one has some idea how it can be achived.
|
|
|
|
|
Right click the Toolbox titlebar and choose "Dockable". Now drag your Toolbox and place it on any side. The Auto Hide button will appear
|
|
|
|
|
I want to create lookup of the type
Field list Conditions: ( i.e >, <,>=) Search
...
...
Data list in the grid based on the condition.
...
OK Cancel
When ever, I call lookup, it has to show me the above form. I must able to send query to this form so as to display filed list and select the data corresponds to that.
How can I do that? And what is best method?
vijaya
|
|
|
|
|
Hey Guys
Need of help on how to longer the session time out in a web site..
I added
<sessionState TimeOut="120"/> in the web config file
I will like to prolong the time out time to two hours
Did i do it the right way cos i have problem on it?
KaKaShi HaTaKe
|
|
|
|
|
HatakeKaKaShi wrote: <sessionState TimeOut="120"/>
Sounds ok...
|
|
|
|
|
What kind of problem do you have?
Maybe it's the lifetime of the authentication cookie (if Forms Authentication)
Maybe ...
I'm not good at guessing, we need more information first...
-^-^-^-^-^-
no risk no funk
|
|
|
|
|
I wanted to display the message box with yes and no button.on the button click event.
for that i am writing the following code.
Dim Msg As String<br />
Dim Icon As Integer<br />
Dim Title As String<br />
Dim Buttons As Integer<br />
Dim Ans As MsgBoxResult<br />
' Fill Message string<br />
Msg = "Are you sure you want to exit?"<br />
' Set dialog Title<br />
Title = "Logout"<br />
' Set icon to critical (X)<br />
Icon = vbQuestion<br />
' Set buttons to abort, retry and ingnore<br />
Buttons = vbYesNo<br />
'Buttons = Buttons + vbDefaultButton2 'set default button to retry<br />
<br />
Ans = MsgBox(Msg, Buttons + Icon, Title)<br />
'alternatively, simply<br />
'Ans = MsgBox(Msg, vbAbortRetryIgnore + vbDefaultButton2 + vbCritical, "Msgbox Example - Abort Retry Ignore")<br />
<br />
' If the user clicked Retry, try again<br />
If Ans = MsgBoxResult.Yes Then<br />
Session("pass") = ""<br />
Response.Redirect("http://136.72.0.5/infoserver/home.htm")<br />
<br />
End If
This code is producing the error.......
Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
|
|
|
|
|
You cannot use MsgBox in Web Application. The MsgBox will show up while running from VS2005, but when you deploy it in IIS it won't show up. So use JavaScript to do so...
|
|
|
|
|
Hi Venkatesh ...
can u provide some code to show the message box using the java script .I need two buttons there Yes and No.and further i need to write some code on yes and no.
|
|
|
|
|
You can use JavaScript "Confirm" box ( Syntax: var res = confirm('Are you sure?'); ) which would have "OK" and "Cancel". But if you still want "Yes", "No" then, I too have to write new code (not possible right now).
|
|
|
|
|
In my project i need to get session idleness bcz if he is not touching the application for few time i need to redirect him to some other page so how can i get the session idle time it might be using session or any state management.Please answer i am waiting it's urgent.
Nagaraj S
|
|
|
|
|
Hi...
I think if the particular session state expires these session("particular") automaticaly becomes nothing or ""
then use the following code.
if(Session("particular")is nothing)
esponse.redirect("Nagaraj.aspx")
|
|
|
|
|
Thank you Sonia ji,
You told after session expiration but i am telling before the session expiration.
Session.Timeout=20;
If it is the condition i need to check the session idleness before 20 min. For example In gmail if you are not performing any task the color of the indicator in chatting list will be changed. I think you got my point
|
|
|
|