my code is
protected void ListView2_OnItemCommand(object sender, ListViewCommandEventArgs e)
{
if (String.Equals(e.CommandName, "forallow"))
{
string[] commandArgs = e.CommandArgument.ToString().Split(new char[] { ',' });
string scrapid = commandArgs[0];
string uid = commandArgs[1];
string imgname = commandArgs[2];
int cat = Convert.ToInt32(scrapid);
int sho = Convert.ToInt32(uid);
string query2 = "update request set status='allow' where request_id='" + cat + "'and shop_id=" + sho + ";update advertisement set imagename='" + imgname + "',shop_id='" + sho + "' where adver_id=" + cat;
cmd = new SqlCommand(query2, connection);
cmd.Connection.Open();
int rows = cmd.ExecuteNonQuery();
if (rows > 0)
{
Response.Write(#"<script language='javascript'>alert('permission granted');</script>");
}
cmd.Connection.Close();
string msgg = "insert into messages(message,shop_id) values('Permission is granted for category id ''" + cat + "' ,'" + sho + "')";
cmd = new SqlCommand(msgg, connection);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();
productfill();
}
}
and html code is
<asp:ListView ID="ListView2" runat="server" OnItemDeleting="ListView2_ItemDeleting" OnItemCommand="ListView2_OnItemCommand">
<LayoutTemplate>
<table runat="server" class="TableCSS">
<tr runat="server" class="TableHeader">
<td runat="server">Advertisement ID</td>
<td runat="server">Advertisement Plan</td>
<td runat="server">Shop ID</td>
<td runat="server">Permission</td>
</tr>
<tr id="ItemPlaceholder" runat="server">
</tr>
<tr runat="server" class="TablePager">
<td runat="server" colspan="3">
<asp:DataPager ID="DataPager1" runat="server">
<Fields>
<asp:NextPreviousPagerField
ButtonType="Button"
ShowFirstPageButton="true"
ShowPreviousPageButton="false"
ShowNextPageButton="true"
ButtonCssClass="PagerButtonCSS"
/>
<asp:NumericPagerField
NumericButtonCssClass="NumericButtonCSS"
NextPreviousButtonCssClass="NextPreviousButtonCSS"
CurrentPageLabelCssClass="CurrentPageLabelCSS"
/>
<asp:NextPreviousPagerField
ButtonType="Button"
ShowNextPageButton="false"
ShowLastPageButton="true"
ButtonCssClass="PagerButtonCSS"
/>
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
<EmptyDataTemplate>
<table runat="server"
style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
<tr>
<td>
NO RECORD FOUND.</td>
</tr>
</table>
</EmptyDataTemplate>
<ItemTemplate>
<tr class="TableData">
<td>
<asp:Label ID="Label2" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"request_id")%>'>
</asp:Label>
</td>
<td>
<asp:Label ID="lblcat" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"adver_plan")%>'>
</asp:Label>
</td>
<td>
<asp:Label ID="Label1" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"shop_id")%>'>
</asp:Label>
</td>
<td> <%-- ValidationGroup="cho" CommandArgument='<%#DataBinder.Eval(Container.DataItem,"request_id")+","+DataBinder.Eval(Container.DataItem,"shop_id")+","+DataBinder.Eval(Container.DataItem,"message")%>'--%>
<asp:Button ID="Button1" runat="server" Text="Allow" Width="45px" CommandName="forallow" ValidationGroup="cho" CommandArgument='<%#DataBinder.Eval(Container.DataItem,"request_id")+","+DataBinder.Eval(Container.DataItem,"shop_id")+","+DataBinder.Eval(Container.DataItem,"message")%>'/><asp:Button ID="Button2" runat="server" Text="Deny" Width="45px" ValidationGroup="2" CommandName="Delete" OnClientClick="return deleteConfirm();"/>
</td>
</tr>
</ItemTemplate>
<EditItemTemplate>
</EditItemTemplate>
</asp:ListView>
plz make this solve as soon as possible
Where is your OnClick event? What is going to make this event fire? If this is all of your code then it will never fire. Recheck your code and make sure you show it all to us.
Related
I have a repeater on my web page that displays Tests data
<form id="frmQuestion">
<div class="panel panel-primary">
<div class="panel-body" style="max-height: 420;overflow-y: scroll;">
<asp:ScriptManager ID="scriptmgr" runat="server"> </asp:ScriptManager>
<asp:UpdatePanel ID="upd" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Repeater ID="rptQuestions" runat="server">
<HeaderTemplate>
<table class="table" cellpadding="5px" cellspacing="10px" border="solid" id="tableQuestion">
<tr style="color:Black; background-color:Teal; border:solid;">
<th style="width:20px">No.</th>
<th style="width:100px">Question</th>
<th style="width:40px">QuestionType</th>
<th style="width:110px">Text Answer</th>
<th style="width:100px">Multiple Choice 1</th>
<th style="width:100px">Multiple Choice 2</th>
<th style="width:100px">Multiple Choice 3</th>
<th style="width:100px">Multiple Choice 4</th>
<th style="width:70px">True/False</th>
<th>Controls</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr style="color:Black; background-color:Silver; border:solid;" id="trdata" class="trclass">
<td id="no"><asp:Label runat="server" ID="lblNo" Text='<%#Eval("Qno") %>' /></td>
<td id="que"><asp:Label runat="server" ID="lblQuestion" Text='<%#Eval("Question") %>'></asp:Label>
<asp:TextBox runat="server" ID="txtQuestion" Text='<%#Eval("Question") %>' Visible="false"></asp:TextBox>
<asp:Label runat="server" ID="lblQid" Text='<%#Eval("Qid") %>' Visible="false"></asp:Label></td>
<td><asp:Label runat="server" ID="lblQtype" Text='<%#Eval("Qtype") %>' ></asp:Label>
<asp:DropDownList runat="server" ID="ddlQType" Visible="false"></asp:DropDownList>
<%-- <select class="dropdown" id="ddlQType" name="ddlQType" style="width:100px" runat="server">
<option value="0">--Select--</option>
<option value="1">Descriptive Answer</option>
<option value="2">Multiple Choice </option>
<option value="3">True/False answer</option></select>--%></td>
<td><asp:Label runat="server" ID="lblAnsDesc" Text='<%#Eval("description") %>' Width="100px" ></asp:Label>
<asp:TextBox runat="server" ID="txtAnsDesc" Text='<%#Eval("description") %>' Width="100px" Visible="false"></asp:TextBox></td>
<td><asp:Label runat="server" ID="lblch1" Text='<%#Eval("choice1") %>' Width="100px" ></asp:Label>
<asp:TextBox runat="server" ID="txtch1" Text='<%#Eval("choice1") %>' Width="100px" Visible="false"></asp:TextBox></td>
<td><asp:Label runat="server" ID="lblch2" Text='<%#Eval("choice2") %>' Width="100px" ></asp:Label>
<asp:TextBox runat="server" ID="txtch2" Text='<%#Eval("choice2") %>' Width="100px" Visible="false"></asp:TextBox></td>
<td><asp:Label runat="server" ID="lblch3" Text='<%#Eval("choice3") %>' Width="100px" ></asp:Label>
<asp:TextBox runat="server" ID="txtch3" Text='<%#Eval("choice3") %>' Width="100px" Visible="false"></asp:TextBox></td>
<td><asp:Label runat="server" ID="lblch4" Text='<%#Eval("choice4") %>' Width="100px" ></asp:Label>
<asp:TextBox runat="server" ID="txtch4" Text='<%#Eval("choice4") %>' Width="100px" Visible="false"></asp:TextBox>
<asp:Label runat="server" ID="lblCorrect" Text='<%#Eval("correct") %>' /></td>
<td><asp:Label runat="server" ID="lblisTrue" Text='<%# Eval("isTrue") %>' Width="70px" ></asp:Label>
<asp:CheckBox runat="server" ID="chkistrue" Checked='<%#(Eval("isTrue")=="true") %>' Width="70px" Visible="false"/></td>
<td> <span class="more"><asp:LinkButton ID="lnkEdit" Text="Edit" runat="server" data-toggle="modal" data-target="#myModal" OnClientClick="getdata();" CausesValidation="false" />
<asp:LinkButton ID="lnkUpdate" Text="Update" runat="server" Visible="false" OnClick="OnUpdate" CausesValidation="false" />
<asp:LinkButton ID="lnkCancel" Text="Cancel" runat="server" Visible="false" OnClick="OnCancel" CausesValidation="false" />
<asp:LinkButton ID="lnkDelete" Text="Delete" runat="server" OnClick="OnDelete" CausesValidation="false" OnClientClick="return confirm('Do you want to delete this row?');" />
</span></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
<!-- Modal example -->
Add Question    
<!-- Modal -->
×
RESULT
--Select--
Descriptive Answer
Multiple Choice
True/False answer
Close
</form>
Now I want to get repeater row data ie question details on btnUpdate_Click event. The server code is
protected void BindRepeater(int tid)
{
try
{
cmd = new SqlCommand("SP_GetQuestions", connection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("#Tid", tid);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
connection.Close();
if (dt.Rows.Count > 0)
{
//adding qno to dt
dt.Columns.Add("Qno",typeof(System.Int32));
for (int i = 0; i < dt.Rows.Count; i++)
{
dt.Rows[i]["Qno"] = i + 1;
}
rptQuestions.DataSource = dt;
rptQuestions.DataBind();
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
protected Question getData()
{
Question question = new Question();
question.qtype = Convert.ToInt32(lblQuestionType.Text);
switch (question.qtype)
{
case 1:
question.ansdesc = textareaAns.InnerText.ToString();
break;
case 2:
question.ch1 = txtMulti1.Text;
question.ch2 = txtMulti2.Text;
question.ch3 = txtMulti3.Text;
question.ch4 = txtMulti4.Text;
question.correct = "";
if (chkmulti1.Checked == true)
question.correct += "1";
if (chkmulti2.Checked == true)
question.correct += "2";
if (chkmulti3.Checked == true)
question.correct += "3";
if (chkmulti4.Checked == true)
question.correct += "4";
break;
case 3:
if (rbtrue.Checked == true)
question.isTrue = true;
if (rbfalse.Checked == true)
question.isTrue = false;
break;
}
return question;
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
Question question = getData();
question.qid = Convert.ToInt32(lblQuestid.Text);
cmd = new SqlCommand("SP_UpdateQuestion", connection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("#question", question.questDesc);
cmd.Parameters.AddWithValue("#qid", question.qid);
cmd.Parameters.AddWithValue("#ans", question.ansdesc);
cmd.Parameters.AddWithValue("#ch1", question.ch1);
cmd.Parameters.AddWithValue("#ch2", question.ch2);
cmd.Parameters.AddWithValue("#ch3", question.ch3);
cmd.Parameters.AddWithValue("#ch4", question.ch4);
cmd.Parameters.AddWithValue("#correct", question.correct);
cmd.Parameters.AddWithValue("#isTrue", question.isTrue);
cmd.Parameters.AddWithValue("#qtype", question.qtype);
try
{
connection.Open();
cmd.ExecuteNonQuery();
connection.Close();
Response.Write("<script>alert('Question updated successfully!');</script>");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
But compiler error occurs as ASP.addquestion_aspx' does not contain a definition for 'OnUpdate' and no extension method 'OnUpdate' accepting a first argument of type 'ASP.addquestion_aspx'
I think button is outside repeater hence the error. How can I access repeater's data in order to update it. Please guide me.
Actually the error was caused because I did not define OnUpdate() method for lnkUpdate button inside repeater. I just removed that button as I no longer needed it and it is working fine now.
I am currently building a CRUD operations on a entity called Payment.
When are click the pages, for instance, page 2, and try to delete the 9th item on page 2,
it will delete the 9th item on page 1 for me.
Here is my code:
protected void btnDelete_Click(object sender, CommandEventArgs e)
{
int paymentId = Convert.ToInt32(e.CommandArgument.ToString());
try
{
using (BillingApplicationDataContext dc = new BillingApplicationDataContext())
{
BLLPayment bllCorporation = new BLLPayment(dc);
bllCorporation.DeletePayment(paymentId);
}
Response.RedirectToRoute("ViewPaymentsRoute");
}
catch
{
Response.RedirectToRoute("ErrorPageRoute", new {
ErrorMsg = "Unable to delete Payment with Id " +
paymentId.ToString() + "." });
}
}
<asp:ListView ID="lstPayment" runat="server" OnPagePropertiesChanging="lstPayment_PagePropertiesChanging"
EnableViewState="false">
<LayoutTemplate>
<fieldset>
<legend>View Payments</legend>
<table cellpadding="0" cellspacing="0">
<tr>
<th>Id</th>
<th>Corporation</th>
<th>Service Contract</th>
<th>Payment Date</th>
<th>Payment Amount</th>
</tr>
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
</table>
</fieldset>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td><asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Id")%>' EnableViewState="false"/></td>
<td><asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "CorpName")%>' EnableViewState="false"/></td>
<td><asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ServiceContractName")%>' EnableViewState="false"/></td>
<td><asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "PaymentDate")%>' EnableViewState="false" /></td>
<td><asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Amount")%>' EnableViewState="false" /></td>
<td>
<%--<asp:Button runat="server" Text="Detail"
OnCommand="btnDetail_Click"
CommandArgument='<%# DataBinder.Eval(Container.DataItem, "Id")%>' EnableViewState="true"/>--%>
<asp:Button ID="btnDelete" Text="Delete" runat="server"
oncommand='btnDelete_Click' CommandArgument='<%# Eval("Id") %>'
OnClientClick="return ConfirmDelete();"/></td>
</tr>
</ItemTemplate>
</asp:ListView>
<asp:DataPager ID="dataPager" runat="server" PagedControlID="lstPayment" EnableViewState="true">
<Fields>
<asp:NumericPagerField ButtonType="Link" />
</Fields>
</asp:DataPager>
<asp:Button runat="server"
ID="btnNew"
oncommand='btnNew_Click'
Text="New"/>
I think there may be something wrong with the page life cycle, but I do not know how to trace.
Why have you commented out
<asp:Button runat="server" Text="Detail"
OnCommand="btnDetail_Click"
**CommandArgument='<%# DataBinder.Eval(Container.DataItem, "Id")%>'** EnableViewState="true"/>
You are trying to retreive the paymentId but you are passing Id as the command argument. I think the line above is absolutely correct.
I guys i have two page On fist page i have my form and on second is report page where my form values store in grid. i have submit button on my form page now when i click on edit link i will redirect to my form page where i can make change and update details. now what i want is when i click on edit link and move to my form page to make editing my submit button change to update button how can i do that...
here is my code for first page:
Select
TRAVELONG
ONETRAVEL
.UK-BSP
.CA-YYZ
.CA-YVR
Partial MCO Refund
<div id="FirstForm" style="margin-left: 80px" runat="server">
<table class="style1">
<tr>
<td class="style13">
<asp:Label ID="lblTid" runat="server" Text="TID"></asp:Label>
</td>
<td class="style5">
<asp:TextBox ID="tbTid" runat="server"></asp:TextBox>
</td>
<td class="style4">
<asp:RequiredFieldValidator ID="rfvTid" runat="server"
ControlToValidate="tbTid" ErrorMessage="Enter Tid" Font-Bold="True"
ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
<td class="style5">
<asp:Label ID="lblUnusedTicketAmount" runat="server"
Text="Unused Ticket Amount"></asp:Label>
</td>
<td class="style11">
<asp:TextBox ID="tbUnusedTicketAmount" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvUnusedTicketAmount" runat="server"
ControlToValidate="tbUnusedTicketAmount" ErrorMessage="Enter Amount"
Font-Bold="True" ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
<td>
<asp:DropDownList ID="ddlUnusedAmount" runat="server">
<asp:ListItem>USD</asp:ListItem>
<asp:ListItem>CAD</asp:ListItem>
<asp:ListItem>GBP</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style14">
<asp:Label ID="lblPNR" runat="server" Text="PNR"></asp:Label>
</td>
<td class="style9">
<asp:TextBox ID="tbPNR" runat="server"></asp:TextBox>
</td>
<td class="style8">
<asp:RequiredFieldValidator ID="rfvPNR" runat="server"
ControlToValidate="tbPNR" ErrorMessage="Enter PNR" Font-Bold="True"
ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
<td class="style9">
<asp:Label ID="lblAirlinePenality" runat="server" Text="Airline Penality"></asp:Label>
</td>
<td class="style12">
<asp:TextBox ID="tbAirlinePenality" runat="server"></asp:TextBox>
</td>
<td class="style10">
<asp:RequiredFieldValidator ID="rfvAirlinePenality" runat="server"
ControlToValidate="tbAirlinePenality" ErrorMessage="Enter Penality"
Font-Bold="True" ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
<td class="style10">
<asp:DropDownList ID="ddlAirlinePenality" runat="server" AutoPostBack="True">
<asp:ListItem>USD</asp:ListItem>
<asp:ListItem>CAD</asp:ListItem>
<asp:ListItem>GBP</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style13">
<asp:Label ID="lblTicketNumber" runat="server" Text="Ticket Number"></asp:Label>
</td>
<td class="style5">
<asp:TextBox ID="tbTicketNumber" runat="server"></asp:TextBox>
</td>
<td class="style4">
<asp:RequiredFieldValidator ID="rfvTicketNumber" runat="server"
ControlToValidate="tbTicketNumber" ErrorMessage="Enter ESAC" Font-Bold="True"
ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
<td class="style5">
<asp:Label ID="lblNetRefundProcess" runat="server" Text="Net Refund Process"></asp:Label>
</td>
<td class="style11">
<asp:TextBox ID="tbNetRefundProcess" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvNetRefundProcess" runat="server"
ControlToValidate="tbNetRefundProcess" ErrorMessage="RequiredFieldValidator"
Font-Bold="True" ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
<td>
<asp:DropDownList ID="ddlNetRefundProcess" runat="server" AutoPostBack="True">
<asp:ListItem>USD</asp:ListItem>
<asp:ListItem>CAD</asp:ListItem>
<asp:ListItem>GBP</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style13">
<asp:Label ID="lblESACCode" runat="server" Text="ESAC Code"></asp:Label>
</td>
<td class="style5">
<asp:TextBox ID="tbESACCode" runat="server"></asp:TextBox>
</td>
<td class="style4">
<asp:RequiredFieldValidator ID="rfvESACCode" runat="server"
ControlToValidate="tbESACCode" ErrorMessage="Enter ESAC code" Font-Bold="True"
ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
<td class="style5">
<asp:Label ID="lblRefundableCommision" runat="server"
Text="Refundable Commission"></asp:Label>
</td>
<td class="style11">
<asp:TextBox ID="tbRefundableCommision" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvRefundableCommission" runat="server"
ControlToValidate="tbRefundableCommision" ErrorMessage="RequiredFieldValidator"
Font-Bold="True" ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
<td>
<asp:DropDownList ID="ddlRefundableCommission" runat="server"
AutoPostBack="True">
<asp:ListItem>USD</asp:ListItem>
<asp:ListItem>CAD</asp:ListItem>
<asp:ListItem>GBP</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style13">
<asp:Label ID="lblWaiverCode" runat="server" Text="Waiver Code"></asp:Label>
</td>
<td class="style5">
<asp:TextBox ID="tbWaiverCode" runat="server"></asp:TextBox>
</td>
<td class="style4">
<asp:RequiredFieldValidator ID="rfvWaiverCode" runat="server"
ControlToValidate="tbWaiverCode" ErrorMessage="Enter Waiver Code"
Font-Bold="True" ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
<td class="style5">
<asp:Label ID="lblCouponRefunded" runat="server" Text="Coupon Refunded"></asp:Label>
</td>
<td class="style11">
<asp:TextBox ID="tbCouponRefund" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvCouponRefunded" runat="server"
ControlToValidate="tbCouponRefund" ErrorMessage="Enter Coupon Refund"
Font-Bold="True" ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
<td>
</td>
</tr>
<tr>
<td class="style13">
<asp:Label ID="Label7" runat="server" Text="Remarks"></asp:Label>
</td>
<td class="style5">
<asp:TextBox ID="tbRemarks" runat="server" TextMode="MultiLine"></asp:TextBox>
</td>
<td class="style4">
<asp:RequiredFieldValidator ID="rfvRemarks" runat="server"
ControlToValidate="tbRemarks" ErrorMessage="Enter Remarks" Font-Bold="True"
ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
<td class="style5">
<asp:Label ID="lblRefundType" runat="server" Text="Refund Type"></asp:Label>
</td>
<td class="style11">
<asp:DropDownList ID="ddlRefundType" runat="server">
<asp:ListItem>Full</asp:ListItem>
<asp:ListItem>Partial</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvRefundType" runat="server"
ControlToValidate="ddlRefundType" ErrorMessage="Select Refund Type"
Font-Bold="True" ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
<td>
</td>
</tr>
<tr>
<td class="style13" colspan="7">
<asp:Button ID="btnSubmit" runat="server" onclick="btnSubmit_Click" Text="Submit"/>
<asp:Button ID="btnReset" runat="server" onclick="btnReset_Click" Text="Reset"/>
</td>
</tr>
</table>
aspx.cs page code:
protected void btnSubmit_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=Bart;Integrated Security=True");
con.Open();
string Portal = ddlPortal.SelectedValue;
string TID = tbTid.Text;
string PNR = tbPNR.Text;
string TicketNumber = tbTicketNumber.Text;
string ESACCode = tbESACCode.Text;
string WaiverCode = tbWaiverCode.Text;
string Remarks = tbRemarks.Text;
string UnusedTicketAmount = tbUnusedTicketAmount.Text;
string UnusedAmount = ddlUnusedAmount.SelectedValue;
string AirlinePenality = tbAirlinePenality.Text;
string Airline = ddlAirlinePenality.SelectedValue;
string NetRefundProcess = tbNetRefundProcess.Text;
string NetRefund = ddlNetRefundProcess.SelectedValue;
string RefundableCommission = tbRefundableCommision.Text;
string Refundable = ddlRefundableCommission.SelectedValue;
string CouponRefunded = tbCouponRefund.Text;
string RefundType = ddlRefundType.SelectedValue;
using (SqlCommand cmd = con.CreateCommand())
{
cmd.CommandText = "insert into Form3(Portal,TID,PNR,TicketNumber,ESACCode,WaiverCode,Remarks,UnusedTicketAmount,ddlUnusedAmount, AirlinePenality, ddlAirlinePenality, NetRefundProcess, ddlNetRefundProcess, RefundableCommission, ddlRefundableCommission, CouponRefunded,RefundType) values('" + Portal + "','" + TID + "','" + PNR + "','" + TicketNumber + "', '" + ESACCode + "', '" + WaiverCode + "', '" + Remarks + "','" + UnusedTicketAmount + "','" + UnusedAmount + "','" + AirlinePenality + "','" + Airline + "','" + NetRefundProcess + "','" + NetRefund + "','" + RefundableCommission + "','" + Refundable + "','" + CouponRefunded + "','" + RefundType + "')";
cmd.Parameters.AddWithValue("#Portal", ddlPortal.SelectedIndex);
cmd.Parameters.AddWithValue("#TID", tbTid.Text.Trim());
cmd.Parameters.AddWithValue("#PNR", tbPNR.Text.Trim());
cmd.Parameters.AddWithValue("#TicketNumber", tbTicketNumber.Text.Trim());
cmd.Parameters.AddWithValue("#ESACCode", tbESACCode.Text.Trim());
cmd.Parameters.AddWithValue("#WaiverCode", tbWaiverCode.Text.Trim());
cmd.Parameters.AddWithValue("#Remarks", tbRemarks.Text.Trim());
cmd.Parameters.AddWithValue("#UnusedTicketAmount", tbUnusedTicketAmount.Text.Trim());
cmd.Parameters.AddWithValue("#ddlUnusedAmount", ddlUnusedAmount.SelectedIndex);
cmd.Parameters.AddWithValue("#AirlinePenality", tbAirlinePenality.Text.Trim());
cmd.Parameters.AddWithValue("#ddlAirlinePenality", ddlAirlinePenality.SelectedIndex);
cmd.Parameters.AddWithValue("#NetRefundProcess", tbNetRefundProcess.Text.Trim());
cmd.Parameters.AddWithValue("#ddlNetRefundProcess", ddlNetRefundProcess.SelectedIndex);
cmd.Parameters.AddWithValue("#RefundableCommission", tbRefundableCommision.Text.Trim());
cmd.Parameters.AddWithValue("#ddlRefundableCommission", ddlRefundableCommission.SelectedIndex);
cmd.Parameters.AddWithValue("#CouponRefunded", tbCouponRefund.Text.Trim());
cmd.Parameters.AddWithValue("#RefundType", ddlRefundType.SelectedIndex);
cmd.ExecuteNonQuery();
}
con.Close();
tbTid.Text = "";
tbPNR.Text = "";
tbTicketNumber.Text = "";
tbESACCode.Text = "";
tbWaiverCode.Text = "";
tbRemarks.Text = "";
tbRemarks.Text = "";
tbUnusedTicketAmount.Text = "";
tbAirlinePenality.Text = "";
tbNetRefundProcess.Text = "";
tbRefundableCommision.Text = "";
tbCouponRefund.Text = "";
lblRefundType.Text = "";
tbTid.Focus();
}
Second report page::
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333"
GridLines="None" AutoGenerateColumns="False"
onrowcommand="GridView1_RowCommand1">
<Columns>
<asp:TemplateField HeaderText="Query">
<itemtemplate>
<asp:LinkButton CommandName="cmdBind" runat="server" Text='<%#Eval("ID")%>' ID="ID" ToolTip='<%#Eval("ID")%>'>LinkButton
</asp:LinkButton>
</itemtemplate>
</asp:TemplateField>
<asp:BoundField DataField="Portal" HeaderText="Portal" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="TID" HeaderText="TID" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="PNR" HeaderText="PNR" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="TicketNumber" HeaderText="Ticket Number" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="ESACCode" HeaderText="ESACCode" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="WaiverCode" HeaderText="WaiverCode" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="Remarks" HeaderText="Remarks" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="UnusedTicketAmount" HeaderText="UnusedTicketAmount" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="ddlUnusedAmount" HeaderText="ddlUnusedAmoun" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="AirlinePenality" HeaderText="AirlinePenality" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="ddlAirlinePenality" HeaderText="ddlAirlinePenality" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="NetRefundProcess" HeaderText="NetRefundProcess" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="ddlNetRefundProcess" HeaderText="ddlNetRefundProcess" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="RefundableCommission" HeaderText="RefundableCommission" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="ddlRefundableCommission" HeaderText="ddlRefundableCommission" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="CouponRefunded" HeaderText="CouponRefunded" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="RefundType" HeaderText="RefundType" ItemStyle-HorizontalAlign="Center"/>
</Columns>
<AlternatingRowStyle BackColor="White" />
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
aspx.cs page of report:
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!Page.IsPostBack)
{
cmd = new SqlCommand("select * from Form3", con);
da = new SqlDataAdapter(cmd);
dt.Clear();
con.Open();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
GridView1.DataSource = dt;
GridView1.DataBind();
}
con.Close();
}
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
protected void GridView1_RowCommand1(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "cmdBind")
{
LinkButton lb = (LinkButton)e.CommandSource;
Response.Redirect("Form.aspx?ID=" + lb.Text + "");
}
}
You need to use a State Management technique to implement this. I have used Session to demonstrate.
On your page where you have the Submit button you need to create a property like this:
public string ButtonTextValue
{
get
{
if (Session["ButtonValue"] == null)
Session["ButtonValue"] = "Submit";
return Convert.ToString(Session["ButtonValue"]);
}
set
{
Session["ButtonValue"] = value;
}
}
On pageload of the same page you need to do this:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
YourButton.Text = ButtonTextValue;
}
}
And on the second page you need to do this:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "cmdBind")
{
LinkButton lb = (LinkButton)e.CommandSource;
Session["ButtonValue"] = "Update";
Response.Redirect("Form.aspx?ID=" + lb.Text + "");
}
}
I need some help about how to paging data from access data base.
I used asp:ListView and asp:DataPager like some example I found but the paging work with javascript and I want the paging will be friendly.
How I can put some of my code?
[edit]
this is the code:
<asp:ListView ID="tblProjects" runat="server" OnPagePropertiesChanging="tblProjects_PagePropertiesChanging">
<LayoutTemplate>
<ul class="ulProducts">
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
</ul>
</LayoutTemplate>
<ItemTemplate>
<li>
<div class="divProduct">
<a rel='pics' href='GalleryEditor/pictures/<%# Eval("BigImageName") %>'>
<img src='GalleryEditor/pictures/<%# Eval("SmallImagesName") %>'
alt='<%# Eval("ImageDetail") %>' title='<%# Eval("ImageDetail") %>' />
</a>
</div>
</li>
</ItemTemplate>
<EmptyDataTemplate>
no data
</EmptyDataTemplate>
This the code behind:
protected void tblProjects_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
{
//set current page startindex, max rows and rebind to false
imagesPager.SetPageProperties(e.StartRowIndex, e.MaximumRows, false);
string page = Request.QueryString["p"];
if (!(FormValidator.IsNumber(page)))
page = "8800";
buildProducts(page);
}
void buildTitleAndDescription(string page)
{
// set page title
OleDbConnection conn0 = new OleDbConnection(#"Provider = Microsoft.Jet.OLEDB.4.0; Data Source =" + Server.MapPath("GalleryEditor\\App_Data\\projects.mdb"));
OleDbCommand comm0 = new OleDbCommand("select ProjectName from Project where PlaceID=" + page, conn0);
OleDbDataReader reader0;
conn0.Open();
reader0 = comm0.ExecuteReader();
reader0.Read();
Page.Header.Title = reader0["ProjectName"].ToString();
reader0.Close();
conn0.Close();
//if (IsPostBack)
//{
// string Script = "<script type='text/javascript'>goToEnd();\n</script>";
// Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", Script);
//}
}
void buildProducts(string page)
{
// set page content
OleDbConnection conn = new OleDbConnection(#"Provider = Microsoft.Jet.OLEDB.4.0; Data Source =" + Server.MapPath("GalleryEditor\\App_Data\\sb.mdb"));
OleDbCommand comm = new OleDbCommand("select SmallImagesName, BigImageName, ImageDetail from Images where PlaceID=" + page, conn);
conn.Open();
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(comm);
da.Fill(ds);
tblProjects.DataSource = ds;
tblProjects.DataBind();
}
I do not mind change the code to better one and if I learn form it I will appreciate it.
All the example I found is for SQL and my data need to be on access.
Here is an example of asp listview you will have to define the querystring as follows.
<asp:ListView ID="ListView1" runat="server" DataKeyNames="bd_book_code"
DataSourceID="SqlDataSource1" EnableModelValidation="True">
<AlternatingItemTemplate>
<tr style="">
<td>
<asp:Label ID="bd_book_codeLabel" runat="server"
Text='<%# Eval("bd_book_code") %>' />
</td>
<td>
<asp:Label ID="bd_isbnLabel" runat="server" Text='<%# Eval("bd_isbn") %>' />
</td>
<td>
<asp:Label ID="bd_titleLabel" runat="server" Text='<%# Eval("bd_title") %>' />
</td>
</tr>
</AlternatingItemTemplate>
<EditItemTemplate>
<tr style="">
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update"
Text="Update" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
Text="Cancel" />
</td>
<td>
<asp:Label ID="bd_book_codeLabel1" runat="server"
Text='<%# Eval("bd_book_code") %>' />
</td>
<td>
<asp:TextBox ID="bd_isbnTextBox" runat="server" Text='<%# Bind("bd_isbn") %>' />
</td>
<td>
<asp:TextBox ID="bd_titleTextBox" runat="server"
Text='<%# Bind("bd_title") %>' />
</td>
</tr>
</EditItemTemplate>
<EmptyDataTemplate>
<table runat="server" style="">
<tr>
<td>
No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert"
Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
Text="Clear" />
</td>
<td>
<asp:TextBox ID="bd_book_codeTextBox" runat="server"
Text='<%# Bind("bd_book_code") %>' />
</td>
<td>
<asp:TextBox ID="bd_isbnTextBox" runat="server" Text='<%# Bind("bd_isbn") %>' />
</td>
<td>
<asp:TextBox ID="bd_titleTextBox" runat="server"
Text='<%# Bind("bd_title") %>' />
</td>
</tr>
</InsertItemTemplate>
<ItemTemplate>
<tr style="">
<td>
<asp:Label ID="bd_book_codeLabel" runat="server"
Text='<%# Eval("bd_book_code") %>' />
</td>
<td>
<asp:Label ID="bd_isbnLabel" runat="server" Text='<%# Eval("bd_isbn") %>' />
</td>
<td>
<asp:Label ID="bd_titleLabel" runat="server" Text='<%# Eval("bd_title") %>' />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table ID="itemPlaceholderContainer" runat="server" border="0" style="">
<tr runat="server" style="">
<th runat="server">
bd_book_code</th>
<th runat="server">
bd_isbn</th>
<th runat="server">
bd_title</th>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" style="">
<asp:DataPager ID="DataPager1" runat="server" QueryStringField="pid">
<Fields>
<asp:NextPreviousPagerField ButtonType="Link" ShowFirstPageButton="True"
ShowNextPageButton="False" ShowPreviousPageButton="False" />
<asp:NumericPagerField />
<asp:NextPreviousPagerField ButtonType="Link" ShowLastPageButton="True"
ShowNextPageButton="False" ShowPreviousPageButton="False" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
<SelectedItemTemplate>
<tr style="">
<td>
<asp:Label ID="bd_book_codeLabel" runat="server"
Text='<%# Eval("bd_book_code") %>' />
</td>
<td>
<asp:Label ID="bd_isbnLabel" runat="server" Text='<%# Eval("bd_isbn") %>' />
</td>
<td>
<asp:Label ID="bd_titleLabel" runat="server" Text='<%# Eval("bd_title") %>' />
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
QueryStringField="pid" will do the magic.
I have nested Repeater. i am using 3 repeater. For calling(firing) the 1st repeater which is working fine and returning 100% result. But when i am calling(firing) 2nd repeater. it is not firing. I just want to know should i call 2nd repeater event if it is in nested format? Or i can not call. If i can call can u suggest how can i call that event?
<asp:UpdatePanel ID="RepeaterPanel" runat="server">
<ContentTemplate>
<div id="mydiv">
<asp:Repeater ID="RpterShareDetails" runat="server" onitemcommand="RpterShareDetails_ItemCommand">
<HeaderTemplate>
<table id="table1">
</HeaderTemplate>
<ItemTemplate>
<tr>
<td rowspan="2" align="center" class="message_repeater_panel_left">
<asp:Image ID="Image1" runat="server" ImageUrl="~/ShowImage.ashx" alt="" width="50" height="50" />
</td>
<td>
<embed src='<%# Eval("FilePath") %>' type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="150" height="150" runat="server" Visible='<%# IsVisible(Eval("UploadType"))%>'></embed>
<asp:ImageButton ID="ibtnHolder" runat="server" Width="130" Height="130" ImageUrl='<%# Eval("FilePath") %>' Visible='<%# NotVisible(Eval("UploadType"))%>' />
</td>
<td class="textTob">
<asp:Label ID="UserCommentLabel" runat="server" Text='<%# Eval("Comments") %>' />
</td>
</tr>
<tr>
<td valign="bottom"> User Keyword:
<asp:Label ID="UserKeywordLabel" runat="server" Text='<%# Eval("Keyword") %>' />
</td>
</tr>
<tr>
<td colspan="2">
<div class="message_repeater_links12">
<span>
<asp:LinkButton ID = "lnkLike" runat = "server" CommandName = "Like">Like</asp:LinkButton>
</span>
<span>
<asp:LinkButton ID="lnk_Comments" runat="server" CommandName="comments" CommandArgument='<%# Eval("Sniffid") %>'>Comments</asp:LinkButton></span>
<span>
<asp:LinkButton ID="lnk_ShowComments" runat="server" CommandName="Show" CommandArgument='<%# Eval("Sniffid") %>'>Show</asp:LinkButton></span>
<span>Share</span>
<asp:Panel ID="Add_Comments" runat="server" Width="90%" class="message_repeater_panel_left">
</asp:Panel>
<asp:Panel ID="Dis_comments" runat="server" Width="90%" class="message_repeater_panel_left">
</asp:Panel>
</div>
</td>
</tr>
<asp:TextBox ID="txt_comment" runat="server" TextMode="MultiLine" Width="300" Visible="false"></asp:TextBox>
<asp:UpdatePanel ID="RepeaterPanel" runat="server" >
<ContentTemplate>
<div style="background-color: #C0C0C0">
<asp:Repeater ID="Rbt_comments" runat="server" onitemcommand="Rbt_comments_ItemCommand1" >
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<%--<div class="message_repeater_panel_left1" >--%>
<tr>
<td>
<span >
<img src="images/photo_sniff.jpg" width="25px" />
<%--<asp:Image ID = "imgCommentPhotos" runat = "server" ImageUrl = "~/AddCommentPhotos.ashx" Width = "25" Height = "25" />--%>
</span>
</td>
<td>
<span><asp:Label ID="UserCommentLabel" runat="server" Text='<%# Eval("Comments") %>' /></span>
</td>
</tr>
<%--</div>
<div class="message_repeater_links12"> --%>
<tr>
<td>
<span><asp:LinkButton ID = "lnkLike" runat = "server" CommandName = "SubLike">Like</asp:LinkButton></span>
</td>
<td>
<span><asp:LinkButton ID="lnk_Comments" runat="server" CommandName="Subcomments">Comments</asp:LinkButton></span>
</td>
<td>
<span><asp:LinkButton ID="lnk_ShowComments" runat="server" CommandName="SubShow">Show</asp:LinkButton></span>
</td>
<td>
<span>Share</span>
</td>
</tr>
<%--</div>--%>
<tr>
<td colspan="4">
<asp:TextBox ID = "txtComment" runat = "server" TextMode="MultiLine" Width="300" Visible = "false"></asp:TextBox>
<div class="message_repeater_panel_left1" ></div>
<div class="message_repeater_links12"></div>
</td>
</tr>
<ContentTemplate>
<div style="background-color: #C0C0C0">
<asp:Repeater ID="rptSubComments" runat="server">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<span >
<img src="images/Santosh.jpg" width="25px" />
<%--<asp:Image ID = "imgCommentPhotos" runat = "server" ImageUrl = "~/AddCommentPhotos.ashx" Width = "25" Height = "25" />--%>
</span>
</td>
<td>
<span><asp:Label ID="lblUserSubComment" runat="server" Text='<%# Eval("Comments") %>' /></span>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</div>
</ContentTemplate>
</ItemTemplate>
<FooterTemplate></table></FooterTemplate>
</asp:Repeater>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
<SeparatorTemplate>
<br />
</SeparatorTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</div>
<br />
<br />
<uc1:CustomPagination ID="RepeaterCustomPagination" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
protected void Rbt_comments_ItemCommand1(object source, RepeaterCommandEventArgs e)
{
try
{
if (e.CommandName == "Subcomments")
{
}
}
catch (Exception ex)
{
}
}
protected void RpterShareDetails_ItemCommand(object source, RepeaterCommandEventArgs e)
{
try
{
if (e.CommandName == "Like")
{
Int32 UserId = Convert.ToInt32(Session["UserID"].ToString());
LikeShareDetails(UserId);
}
if (e.CommandName == "comments")
{
LinkButton btn = e.CommandSource as LinkButton;
if (btn != null)
{
TextBox txt = (TextBox)e.Item.FindControl("txt_comment");
txt.Visible = true;
txt.Attributes.Add("OnKeyPress", "isNumberKey(this,"+ e.CommandArgument.ToString() +")");
Panel Panel2 = (Panel)e.Item.FindControl("Add_Comments");
Literal lt = new Literal(); lt.Text = "<br />";
Panel2.Controls.Add(lt);
Panel2.Controls.Add(txt);
DataTable dt = new DataTable();
Repeater gv = (Repeater)e.Item.FindControl("Rbt_comments");
SqlConnection sqlCon = new SqlConnection();
sqlCon.ConnectionString = ConfigurationManager.ConnectionStrings["ISnifferDBConnectionString"].ConnectionString;
//sqlCon.ConnectionString = CommonUtil.GetConfigValue("ISnifferDBConnectionString");
string strSql = "select Comments from Comments where SniffId in ('" + e.CommandArgument.ToString() + "') order by CommentId desc";
SqlCommand sqlComd = new SqlCommand(strSql, sqlCon);
sqlCon.Open();
SqlDataAdapter sqlAdpt = new SqlDataAdapter();
sqlAdpt.SelectCommand = sqlComd;
sqlAdpt.Fill(dt);
int row = dt.Rows.Count;
if (row >= 1)
{
gv.DataSource = dt;
gv.DataBind();
}
else
{
dt.Rows.Add("No Comments");
gv.DataSource = dt;
gv.DataBind();
}
Panel Panel1 = (Panel)e.Item.FindControl("Dis_comments");
Panel1.Controls.Add(gv);
}
}
}
}