|
Hi
I have produced a table which allows me to select the current user or delete the user from the table
But i am unsure how to handle both events, i have the delete working, but when i try to run the select method, it will run both the delete and select methods, how do I handle these correctly my asp code is as follows
<asp:TemplateColumn HeaderText="Delete User">
<ItemTemplate >
<asp:linkbutton id="cmdDel" runat="server">Delete</asp:linkbutton>
</ItemTemplate></asp:TemplateColumn>
<asp:TemplateColumn HeaderText ="View user Profile">
<ItemTemplate>
<asp:LinkButton ID="cmdSelect" runat="server" >Select</asp:LinkButton></ItemTemplate></asp:TemplateColumn>
</Columns>
<PagerStyle HorizontalAlign="Left" />
<AlternatingItemStyle BackColor="ActiveBorder" />
<HeaderStyle BackColor="Navy" Font-Bold="True" ForeColor="White" HorizontalAlign="Center" />
</asp:datagrid>
and my vb code is
Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs) Handles dgPriv.ItemDataBound
Dim l As LinkButton
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
l = CType(e.Item.Cells(6).FindControl("cmdDel"), LinkButton)
l.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this item?');")
End If
End Sub
Sub dgpriv_ItemCommand(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles dgPriv.ItemCommand
Dim iid As Integer = dgPriv.DataKeys(e.Item.ItemIndex)
Dim litErr As New Literal
Dim myConnection As New MySqlConnection("Server=localhost;;database=ftp1;")
Try
Dim param As New MySqlParameter
Dim myDeleteCommand As MySqlCommand = New MySqlCommand("sp_delete", myConnection)
myDeleteCommand.CommandType = CommandType.StoredProcedure
param = myDeleteCommand.Parameters.Add("?p_id", MySqlDbType.VarChar)
param.Direction = ParameterDirection.Input
param.Value = iid
myConnection.Open() 'Open the connection
myDeleteCommand.ExecuteNonQuery() 'Delete the record
myConnection.Close() 'Close the connection
Catch ex As Exception
litErr.Text = ex.Message
MsgBox(ex.Message)
End Try
refresh()
End Sub
Sub getUser(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles dgPriv.ItemCommand
MsgBox(dgPriv.DataKeys(e.Item.ItemIndex))
End Sub
|
|
|
|
|
boyindie wrote: i have the delete working, but when i try to run the select method, it will run both the delete and select methods,
Yes it will fire same ItemCommand event. You need to check the CommandName inside this event. Do like
if e.CommandName = "Delete"
'Delete
End If . Make sure that you are setting command name for the link button's
|
|
|
|
|
hi,
when ur doing any datagrid operation rowdatabound, itemdatabound, and if ur select then selectedindex changing fires
so if u r doing something like delete , update in itemdatabound event then
better to check first which operation u r performing,
how to check this,
if ur using templates for delete column then the button in that template has property CommandName give any name(Delete) & check the same at itemdatabound event
if ur not using templates then bydefault its command name is "Delete" for Delete Button
<br />
if(e.CommandName == "Delete")<br />
{<br />
}<br />
if(e.Commandname == "Update")<br />
{<br />
}<br />
Amit Metkar
3i-infotech, Mumbai.
|
|
|
|
|
Hello!
How ca I do a query in crystal report where I will set a condition on what report data it will show?
Let say I have a textbox that will specify a particular date so may report will show the indicated date.
Kindly give me a tutorial.
Thanks.
|
|
|
|
|
isaii wrote: Let say I have a textbox that will specify a particular date so may report will show the indicated date.
I suggest you to query DB and get result for the indicated date. Get results to a DataSet. Now set report source as this DataSet.
|
|
|
|
|
I want to send mail and read mail for from and subject fields from
SMTP,Exchange server and lotus note in application, anybody have any idea
about this ....any site where i can find solution...i serached alot but not
find any good solution...
pallavi
|
|
|
|
|
Sending mail can be done very easily by using System.Net.Mail.
Receiving mails is a little bit complicated but not so much. You can use Outlook dll or OpenStmp opensource framework for that.
|
|
|
|
|
thanks Michael
can i use exchange server ,lotus notes for reading mail's content in same way as we use smtp.. as i dont know much about exchange server and lotus notes
pallavi
|
|
|
|
|
I have some experienced with Microsoft Exchange Server. I think I used outlook dll or Opensmtp in that project.. but no idea about Lotus.
|
|
|
|
|
|
Hi There,
I am looking for a little help with direction on how to do the above.
Basically I have a sql database which contains a table of properties - this table contains a description col, a group col and the type of custom control to use. The customer has control over this table and can add extra entries to this table, therefore these extra properties need to be displayed in the htlm.
Currently I am creating ASP repeaters in the code behind, as for each of the different groups returned from the table these need to be within a panel that can be collapsed - I have no idea how many different groups will be required - this is why I have to do it in the code behind.
Also within each group, becuase I dont know what type of control I need to add until the data is returned from the database I also add these controls in the code behind.
If this explaination makes any sence to anyone : is there a better way of doing this - as the properties page takes too long to render?
Thanks
Janet
|
|
|
|
|
DixonJM wrote: this table contains a description col, a group col and the type of custom control to use.
Will your table look like this ?
Description Group Control
-------------------------------
A textbox TxtGroup TextBox
DixonJM wrote: Currently I am creating ASP repeaters in the code behind,
If I understood you properly, I don't think the need of a repeater. You can create table's from codebehind by putting HTML code to Response. One more question, if you are making all control dynamic, how you will take value from the control. I think ASP.NET won't maintain state for dynamically created controls ? Is it ?
|
|
|
|
|
Hi there,
My table, in more details, looks like this:-
Description Group Control MinVal MaxVal MaxLength
-----------------------------------------------------------------------
Own site name Main TextBox 1 40 40
Own Site Tel Main TextBox 1 20 20
Own site ID Main NumericText 1 999 3
Area Code Setting NumericText 0 10 2
The main reason I used a repeater is so that I could use the databind method from the above dataset to add my controls in the code behind?
Thx
janet
Sorry above table looks naff - dont know how to add in table as you did in your post?
|
|
|
|
|
Sorry, I don't think that I can help you since I find a better solution than your current one.
|
|
|
|
|
Hi All;
I'm asp.net noob
Please tell my how to make a simple Database Class by Code (C#) with simple CRUD functions, I mean, I do not know hot to connect to databse ansd manipulate it form code (Database is stored in App_Data).
Thanks
|
|
|
|
|
There are loads of samples and tutorials on the microsoft site - you should just go and have a look at some of these.
Also buying a book might not be a bad idea...
|
|
|
|
|
if u want to retrive data from the database when u click on the, for example, search button, double click on the button and wite the following code behind it to establish connection
**********************************************************
String strConnection;
strConnection = "server=localhost;User ID=sa;Password=sasa;database=rescue15";
SqlConnection conn = new SqlConnection(strConnection);
conn.Open();
*********************************************************
|
|
|
|
|
if u want to retrive data from the database when u click on the, for example, search button, double click on the button and wite the following code behind it to establish connection
**********************************************************
String strConnection;
strConnection = "server=localhost;User ID=sa; password=sasa;database=rescue15";
SqlConnection conn = new SqlConnection(strConnection);
conn.Open();
*********************************************************
|
|
|
|
|
HI!
A TextBox Just Accept Integer values i.e 123 using asp.net and vb.net
|
|
|
|
|
fmlove wrote: A TextBox Just Accept Integer values i.e 123 using asp.net and vb.net
Is that a TextBox Problem ?
|
|
|
|
|
Well, If I get you correctly; you are interested in having a textbox which only accepts integer values. Am I rite?
If so, you can use the following code.
Hi,
this following code allows only integers.
<script language="javascript" type="text/javascript">
function intOnly(i)
{
if(i.value.length>0)
{
i.value = i.value.replace(/[^\d]+/g, '');
}
}
</script>
<asp:TextBox id="TextBox1" style="Z-INDEX: 102; LEFT: 240px; POSITION: absolute; TOP: 152px" Runat="server" onChange="intOnly(this);" onKeyUp="intOnly(this);" onKeyPress="intOnly(this);"></asp:TextBox>
|
|
|
|
|
Thanx for This Kindness.............
|
|
|
|
|
hi
i want to know how to hide the values in query string in ASP.net.
here i want to send the values from one page to another page through query
string with out explicitly visible the values in the query string. i want
the solution with the response.redirect method.
example : www.mysite.com/member.aspx?id=123&name=coco
but i wan the link is www.mysite.com/member.aspx only.
I dont want use Session, or cache.this will make heavy my application
if anybody knows please send me the solution.it's very needed to me.
Thank You
Ramakant Singh
|
|
|
|
|
ramakant_1352 wrote: i want to send the values from one page to another page through query
string with out explicitly visible the values in the query string. i want
the solution with the response.redirect method.
Then you could use some URLRewritting techniques. If you can use Server.Transfer() , you can add items to Context. But you can't use this with Response.Redirect since Context only stays in scope until the page is sent to the browser
|
|
|
|
|
Use property for ID and Name
Best Regard
Pathan
GOD HELP THOSE WHO HELP THEMSELVES
|
|
|
|